Removing the strings and tensorlist TF support. (#6248)
Neither of these are currently in use and would be done differently today
vs. when they were initially implemented 2 years ago before both MLIR and
IREE grew a lot of support. We can add them back as more purely frontend
implementations (using !iree.list, etc) as/if needed.
diff --git a/bindings/python/iree/runtime/CMakeLists.txt b/bindings/python/iree/runtime/CMakeLists.txt
index bca19f4..8d2f26e 100644
--- a/bindings/python/iree/runtime/CMakeLists.txt
+++ b/bindings/python/iree/runtime/CMakeLists.txt
@@ -25,8 +25,6 @@
iree::hal
iree::hal::drivers
iree::modules::hal
- iree::modules::strings::strings_module
- iree::modules::tensorlist::native_module
iree::vm
iree::vm::bytecode_module
absl::inlined_vector
diff --git a/bindings/python/iree/runtime/system_api.py b/bindings/python/iree/runtime/system_api.py
index 4f4a5fc..cb7d0b3 100644
--- a/bindings/python/iree/runtime/system_api.py
+++ b/bindings/python/iree/runtime/system_api.py
@@ -116,9 +116,7 @@
driver_name.split(",") if driver_name is not None else None)
self.device = self.driver.create_default_device()
hal_module = _binding.create_hal_module(self.device)
- strings_module = _binding.create_strings_module()
- tensorlist_module = _binding.create_tensorlist_module()
- self.default_vm_modules = (hal_module, strings_module, tensorlist_module)
+ self.default_vm_modules = (hal_module,)
_global_config = None
diff --git a/bindings/python/iree/runtime/vm.cc b/bindings/python/iree/runtime/vm.cc
index 7c272ae..325ba1f 100644
--- a/bindings/python/iree/runtime/vm.cc
+++ b/bindings/python/iree/runtime/vm.cc
@@ -14,8 +14,6 @@
#include "iree/base/status.h"
#include "iree/hal/api.h"
#include "iree/modules/hal/hal_module.h"
-#include "iree/modules/strings/strings_module.h"
-#include "iree/modules/tensorlist/native_module.h"
#include "iree/vm/api.h"
#include "pybind11/numpy.h"
@@ -32,21 +30,6 @@
return VmModule::CreateRetained(module);
}
-VmModule CreateStringsModule() {
- iree_vm_module_t* module;
- CheckApiStatus(iree_strings_module_create(iree_allocator_system(), &module),
- "Error creating trings module");
- return VmModule::CreateRetained(module);
-}
-
-VmModule CreateTensorListModule() {
- iree_vm_module_t* module;
- CheckApiStatus(
- iree_tensorlist_module_create(iree_allocator_system(), &module),
- "Error creating tensorlist module");
- return VmModule::CreateRetained(module);
-}
-
// RAII wrapper for a Py_buffer which calls PyBuffer_Release when it goes
// out of scope.
class PyBufferReleaser {
@@ -477,13 +460,9 @@
void SetupVmBindings(pybind11::module m) {
IREE_CHECK_OK(iree_vm_register_builtin_types());
IREE_CHECK_OK(iree_hal_module_register_types());
- IREE_CHECK_OK(iree_tensorlist_module_register_types());
- IREE_CHECK_OK(iree_strings_module_register_types());
// Built-in module creation.
m.def("create_hal_module", &CreateHalModule);
- m.def("create_strings_module", &CreateStringsModule);
- m.def("create_tensorlist_module", &CreateTensorListModule);
py::enum_<enum iree_vm_function_linkage_e>(m, "Linkage")
.value("INTERNAL", IREE_VM_FUNCTION_LINKAGE_INTERNAL)
diff --git a/integrations/tensorflow/e2e/BUILD b/integrations/tensorflow/e2e/BUILD
index 16a0d19..8aba0c5 100644
--- a/integrations/tensorflow/e2e/BUILD
+++ b/integrations/tensorflow/e2e/BUILD
@@ -75,8 +75,6 @@
"simple_stateful_test.py",
"sliding_window_test.py",
"space_to_batch_nd_test.py",
- "strings_test.py",
- "tensorlist_test.py",
]
# keep sorted
diff --git a/integrations/tensorflow/e2e/CMakeLists.txt b/integrations/tensorflow/e2e/CMakeLists.txt
index 700079b..bcc55be 100644
--- a/integrations/tensorflow/e2e/CMakeLists.txt
+++ b/integrations/tensorflow/e2e/CMakeLists.txt
@@ -19,7 +19,7 @@
"target_backends"
"reference_backend"
MATRIX_VALUES
- "batch_norm_test.py;batch_to_space_nd_test.py;broadcast_to_test.py;broadcasting_test.py;concat_test.py;control_flow_test.py;conv_test.py;conv_transpose_test.py;depth_conv_test.py;dynamic_mlp_relu_test.py;dynamic_mlp_test.py;einsum_dynamic_test.py;einsum_static_test.py;einsum_vector_test.py;fft_test.py;fill_test.py;gather_test.py;image_resize_test.py;linspace_test.py;mandelbrot_test.py;matrix_ops_dynamic_test.py;matrix_ops_static_test.py;pytree_test.py;quantization_dyn_test.py;quantization_test.py;range_test.py;resource_ops_test.py;ring_buffer_test.py;scatter_update_test.py;simple_arithmetic_test.py;simple_stateful_test.py;sliding_window_test.py;space_to_batch_nd_test.py;strings_test.py;tensorlist_test.py"
+ "batch_norm_test.py;batch_to_space_nd_test.py;broadcast_to_test.py;broadcasting_test.py;concat_test.py;control_flow_test.py;conv_test.py;conv_transpose_test.py;depth_conv_test.py;dynamic_mlp_relu_test.py;dynamic_mlp_test.py;einsum_dynamic_test.py;einsum_static_test.py;einsum_vector_test.py;fft_test.py;fill_test.py;gather_test.py;image_resize_test.py;linspace_test.py;mandelbrot_test.py;matrix_ops_dynamic_test.py;matrix_ops_static_test.py;pytree_test.py;quantization_dyn_test.py;quantization_test.py;range_test.py;resource_ops_test.py;ring_buffer_test.py;scatter_update_test.py;simple_arithmetic_test.py;simple_stateful_test.py;sliding_window_test.py;space_to_batch_nd_test.py"
"tf;tflite;iree_llvmaot;iree_vulkan"
"tf"
FAILING_CONFIGURATIONS
diff --git a/integrations/tensorflow/e2e/strings_test.py b/integrations/tensorflow/e2e/strings_test.py
deleted file mode 100644
index ac2143a..0000000
--- a/integrations/tensorflow/e2e/strings_test.py
+++ /dev/null
@@ -1,89 +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
-
-import string
-
-from absl import app
-from iree.tf.support import tf_test_utils
-import numpy as np
-import tensorflow.compat.v2 as tf
-
-
-class StringsModule(tf.Module):
- """A Module for converting a set of ids to the concatenated string."""
-
- def __init__(self):
- wordparts = [str(c) for c in string.printable]
- self.wordparts = tf.constant(wordparts, tf.string)
-
- @tf.function(input_signature=[
- tf.TensorSpec((None, None), dtype=tf.int32),
- ])
- def print_ids(self, ids):
- string_tensor = tf.strings.as_string(ids)
- tf.print(string_tensor)
-
- @tf.function(input_signature=[
- tf.TensorSpec((None,), dtype=tf.int32),
- tf.TensorSpec((None,), dtype=tf.int32),
- ])
- def gather(self, string_values, indices):
- tf.print(tf.gather(tf.as_string(string_values), indices))
-
-# @tf.function(input_signature=[
-# tf.TensorSpec((None, None), dtype=tf.int32),
-# ])
-# def strings_to_ids(self, ids):
-# wps = tf.gather(self.wordparts, ids)
-# return tf.strings.reduce_join(wps, 1)
-
-
-class StringsTest(tf_test_utils.TracedModuleTestCase):
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self._modules = tf_test_utils.compile_tf_module(StringsModule)
-
- def test_print_ids(self):
-
- def print_ids(module):
- input_ids = np.asarray([[1, 2, 3, 4, 5, 6], [10, 11, 12, 14, 15, 16]],
- dtype=np.int32)
- module.print_ids(input_ids)
-
- self.compare_backends(print_ids, self._modules)
-
- def test_gather(self):
-
- def gather(module):
- string_values = np.asarray([ord(c) for c in string.printable],
- dtype=np.int32)
- input_indices = np.asarray([12, 10, 29, 21, 10, 34], dtype=np.int32)
- module.gather(string_values, input_indices)
-
- self.compare_backends(gather, self._modules)
-
-
-# def test_strings_to_ids(self):
-#
-# def strings_to_ids(module):
-# input_ids = np.asarray(
-# [[12, 10, 29, 28, 94, 15, 24, 27, 94, 25, 21, 10, 34],
-# [13, 24, 16, 28, 94, 15, 24, 27, 94, 28, 29, 10, 34]])
-# module.strings_to_ids(input_ids)
-#
-# self.compare_backends(strings_to_ids, self._modules)
-
-
-def main(argv):
- del argv # Unused
- if hasattr(tf, 'enable_v2_behavior'):
- tf.enable_v2_behavior()
- tf.test.main()
-
-
-if __name__ == '__main__':
- app.run(main)
diff --git a/integrations/tensorflow/e2e/tensorlist_test.py b/integrations/tensorflow/e2e/tensorlist_test.py
deleted file mode 100644
index b115463..0000000
--- a/integrations/tensorflow/e2e/tensorlist_test.py
+++ /dev/null
@@ -1,121 +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
-
-from absl import app
-from iree.tf.support import tf_test_utils
-from iree.tf.support import tf_utils
-import numpy as np
-import tensorflow.compat.v2 as tf
-
-STATIC_SIZE = 20
-
-
-class TensorListModule(tf.Module):
-
- def __init__(self):
- pass
-
- @tf.function(input_signature=[tf.TensorSpec([], tf.float32)])
- def identity_through_tensorlist(self, x):
- ta = tf.TensorArray(dtype=tf.float32, size=1, element_shape=[])
- ta = ta.write(0, x)
- return ta.read(0)
-
- @tf.function(input_signature=[
- tf.TensorSpec([], tf.float32),
- tf.TensorSpec([], tf.float32)
- ])
- def add_through_tensorlist(self, a, b):
- ta = tf.TensorArray(dtype=tf.float32, size=2, element_shape=[])
- ta = ta.write(0, a)
- ta = ta.write(1, b)
- return ta.read(0) + ta.read(1)
-
- @tf.function(input_signature=[tf.TensorSpec([STATIC_SIZE], tf.float32)])
- def slice_first_element_with_from_tensor(self, t):
- ta = tf.TensorArray(dtype=tf.float32, size=STATIC_SIZE, element_shape=[])
- ta = ta.unstack(t)
- return ta.read(0)
-
- @tf.function(
- input_signature=[tf.TensorSpec([STATIC_SIZE, STATIC_SIZE], tf.float32)])
- def slice_first_element_with_from_tensor_high_rank(self, t):
- ta = tf.TensorArray(dtype=tf.float32,
- size=STATIC_SIZE,
- element_shape=[STATIC_SIZE])
- ta = ta.unstack(t)
- return ta.read(0)
-
- @tf.function(input_signature=[
- tf.TensorSpec([], tf.float32),
- tf.TensorSpec([], tf.float32)
- ])
- def concat_with_tensorlist_stack(self, a, b):
- ta = tf.TensorArray(dtype=tf.float32, size=2, element_shape=[])
- ta = ta.write(0, a)
- ta = ta.write(1, b)
- return ta.stack()
-
- @tf.function(input_signature=[tf.TensorSpec([], tf.float32)])
- def partially_empty_stack(self, x):
- ta = tf.TensorArray(dtype=tf.float32, size=2, element_shape=[])
- ta = ta.write(0, x)
- return ta.stack()
-
-
-class TensorListTest(tf_test_utils.TracedModuleTestCase):
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self._modules = tf_test_utils.compile_tf_module(TensorListModule)
-
- # yapf: disable
- def test_identity_through_tensorlist(self):
- def identity_through_tensorlist(module):
- module.identity_through_tensorlist(np.array(42., dtype=np.float32))
- self.compare_backends(identity_through_tensorlist, self._modules)
-
- def test_add_through_tensorlist(self):
- def add_through_tensorlist(module):
- module.add_through_tensorlist(np.array(42., dtype=np.float32),
- np.array(43., dtype=np.float32))
- self.compare_backends(add_through_tensorlist, self._modules)
-
- def test_slice_first_element_with_from_tensor(self):
- def slice_first_element_with_from_tensor(module):
- module.slice_first_element_with_from_tensor(
- np.arange(STATIC_SIZE, dtype=np.float32))
- self.compare_backends(slice_first_element_with_from_tensor, self._modules)
-
- def test_slice_first_element_with_from_tensor_high_rank(self):
- def slice_first_element_with_from_tensor_high_rank(module):
- module.slice_first_element_with_from_tensor_high_rank(
- tf_utils.ndarange([STATIC_SIZE, STATIC_SIZE]))
- self.compare_backends(slice_first_element_with_from_tensor_high_rank,
- self._modules)
-
- def test_concat_with_tensorlist_stack(self):
- def concat_with_tensorlist_stack(module):
- module.concat_with_tensorlist_stack(np.array(42., dtype=np.float32),
- np.array(43., dtype=np.float32))
- self.compare_backends(concat_with_tensorlist_stack, self._modules)
-
- def test_partially_empty_stack(self):
- def partially_empty_stack(module):
- module.partially_empty_stack(np.array(42., dtype=np.float32))
- self.compare_backends(partially_empty_stack, self._modules)
- # yapf: enable
-
-
-def main(argv):
- del argv # Unused
- if hasattr(tf, 'enable_v2_behavior'):
- tf.enable_v2_behavior()
- tf.test.main()
-
-
-if __name__ == '__main__':
- app.run(main)
diff --git a/integrations/tensorflow/iree_tf_compiler/BUILD b/integrations/tensorflow/iree_tf_compiler/BUILD
index cfb51a0..f432ade 100644
--- a/integrations/tensorflow/iree_tf_compiler/BUILD
+++ b/integrations/tensorflow/iree_tf_compiler/BUILD
@@ -33,13 +33,9 @@
deps = [
"//iree_tf_compiler/MHLO",
"//iree_tf_compiler/TF",
- "//iree_tf_compiler/dialect/tf_strings/ir:dialect",
- "//iree_tf_compiler/dialect/tf_tensorlist/ir:tf_tensorlist_dialect",
"@iree//iree/compiler/Dialect/Flow/IR",
"@iree//iree/compiler/Dialect/HAL/IR",
"@iree//iree/compiler/Dialect/IREE/IR",
- "@iree//iree/compiler/Dialect/Modules/Strings/IR:Dialect",
- "@iree//iree/compiler/Dialect/Modules/TensorList/IR",
"@iree//iree/tools:init_xla_dialects",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
diff --git a/integrations/tensorflow/iree_tf_compiler/MHLO/Passes.h b/integrations/tensorflow/iree_tf_compiler/MHLO/Passes.h
index f416128..8572e50 100644
--- a/integrations/tensorflow/iree_tf_compiler/MHLO/Passes.h
+++ b/integrations/tensorflow/iree_tf_compiler/MHLO/Passes.h
@@ -36,8 +36,6 @@
// Registration
//===----------------------------------------------------------------------===//
-void registerAllDialects(mlir::DialectRegistry ®istry);
-
inline void registerAllPasses() {
registerMHLOImportPassPipeline();
diff --git a/integrations/tensorflow/iree_tf_compiler/TF/BUILD b/integrations/tensorflow/iree_tf_compiler/TF/BUILD
index 95ae154..569cc25 100644
--- a/integrations/tensorflow/iree_tf_compiler/TF/BUILD
+++ b/integrations/tensorflow/iree_tf_compiler/TF/BUILD
@@ -31,12 +31,6 @@
],
deps = [
"//iree_tf_compiler/MHLO",
- "//iree_tf_compiler/dialect/tf_strings/conversion:convert_tf_strings_to_strings",
- "//iree_tf_compiler/dialect/tf_strings/conversion:convert_tf_to_tf_strings",
- "//iree_tf_compiler/dialect/tf_strings/ir:dialect",
- "//iree_tf_compiler/dialect/tf_tensorlist/conversion:convert_tf_tensorlist_to_tensorlist",
- "//iree_tf_compiler/dialect/tf_tensorlist/conversion:convert_tf_to_tf_tensorlist",
- "//iree_tf_compiler/dialect/tf_tensorlist/ir:tf_tensorlist_dialect",
"@iree//iree/compiler/Dialect/Flow/IR",
"@iree//iree/compiler/Dialect/Flow/Transforms",
"@iree//iree/compiler/Dialect/HAL/IR",
diff --git a/integrations/tensorflow/iree_tf_compiler/TF/Passes.cpp b/integrations/tensorflow/iree_tf_compiler/TF/Passes.cpp
index f86d99d..5a9c462 100644
--- a/integrations/tensorflow/iree_tf_compiler/TF/Passes.cpp
+++ b/integrations/tensorflow/iree_tf_compiler/TF/Passes.cpp
@@ -9,8 +9,6 @@
#include "iree/compiler/Dialect/Flow/Transforms/Passes.h"
#include "iree/compiler/Dialect/Shape/Transforms/Passes.h"
#include "iree_tf_compiler/MHLO/Passes.h"
-#include "iree_tf_compiler/dialect/tf_strings/ir/dialect.h"
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.h"
#include "mlir-hlo/Dialect/mhlo/transforms/passes.h"
#include "mlir/Dialect/Shape/Transforms/Passes.h"
#include "mlir/Pass/PassManager.h"
@@ -23,11 +21,6 @@
namespace iree_integrations {
namespace TF {
-void registerAllDialects(mlir::DialectRegistry ®istry) {
- registry.insert<tf_strings::TFStringsDialect>();
- registry.insert<tf_tensorlist::TFTensorListDialect>();
-}
-
// All IREE-specific passes that lower TF representations before reaching the
// IREE core should go here.
void buildTFImportPassPipeline(OpPassManager &pm) {
@@ -67,12 +60,6 @@
pm.addPass(createCanonicalizerPass());
//----------------------------------------------------------------------------
- // Lowering module specific TF behavior to intermediate dialects.
- //----------------------------------------------------------------------------
- pm.addPass(tf_strings::createConvertTFToTFStringsPass());
- pm.addPass(tf_tensorlist::createConvertTFToTFTensorListPass());
-
- //----------------------------------------------------------------------------
// Legalize to XLA
//----------------------------------------------------------------------------
pm.addPass(createConvertToMHLOPass());
@@ -94,12 +81,6 @@
// pm.addPass(createCanonicalizerPass());
//----------------------------------------------------------------------------
- // Lowering intermediate dialects to module specific dialects.
- //----------------------------------------------------------------------------
- pm.addPass(tf_strings::createConvertTFStringsToStringsPass());
- pm.addPass(tf_tensorlist::createConvertTFTensorListToTensorListPass());
-
- //----------------------------------------------------------------------------
// Lowering tf_saved_model dialect to IREE dialects
//----------------------------------------------------------------------------
// First, eliminate tf_saved_model.global_tensor's and corresponding
diff --git a/integrations/tensorflow/iree_tf_compiler/TF/Passes.h b/integrations/tensorflow/iree_tf_compiler/TF/Passes.h
index f20d428..fb88bec 100644
--- a/integrations/tensorflow/iree_tf_compiler/TF/Passes.h
+++ b/integrations/tensorflow/iree_tf_compiler/TF/Passes.h
@@ -7,10 +7,6 @@
#ifndef IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_TF_PASSES_H_
#define IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_TF_PASSES_H_
-#include "iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_strings_to_strings.h"
-#include "iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.h"
-#include "iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_tensorlist_to_tensorlist.h"
-#include "iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.h"
#include "mlir/Pass/Pass.h"
namespace mlir {
@@ -65,8 +61,6 @@
// Registration
//===----------------------------------------------------------------------===//
-void registerAllDialects(mlir::DialectRegistry ®istry);
-
inline void registerAllPasses() {
registerTFImportPassPipeline();
@@ -79,11 +73,6 @@
createStripModuleMetadataPass();
createStripFunctionMetadataPass();
createVerifyFullyConvertedPass();
-
- tf_strings::createConvertTFToTFStringsPass();
- tf_strings::createConvertTFStringsToStringsPass();
- tf_tensorlist::createConvertTFTensorListToTensorListPass();
- tf_tensorlist::createConvertTFToTFTensorListPass();
}
} // namespace TF
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/README.md b/integrations/tensorflow/iree_tf_compiler/dialect/README.md
deleted file mode 100644
index 9fb4a06..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Dialects used for interfacing to TensorFlow.
-
-This directory should be structured similar to `iree/compiler/Dialect`, except
-that google naming conventions are used throughout. The reason for this is that
-these dialects should in principle be useful to any TensorFlow compiler, and
-potentially will be upstreamed into the main TensorFlow repo.
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/BUILD b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/BUILD
deleted file mode 100644
index f8e4776..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/BUILD
+++ /dev/null
@@ -1,19 +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
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-cc_library(
- name = "tf_strings",
- deps = [
- "//iree_tf_compiler/dialect/tf_strings/conversion",
- "//iree_tf_compiler/dialect/tf_strings/ir",
- ],
-)
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/BUILD b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/BUILD
deleted file mode 100644
index 2de2cd8..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/BUILD
+++ /dev/null
@@ -1,86 +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
-
-# Transforms specific to the IREE Strings module.
-
-load("@iree//build_tools/bazel:tblgen.bzl", "gentbl_cc_library")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-cc_library(
- name = "conversion",
- deps = [
- ":convert_tf_strings_to_strings",
- ":convert_tf_to_tf_strings",
- ],
-)
-
-cc_library(
- name = "convert_tf_strings_to_strings",
- srcs = [
- "convert_tf_strings_to_strings.cc",
- ],
- hdrs = [
- "convert_tf_strings_to_strings.h",
- ],
- deps = [
- "//iree_tf_compiler/dialect/tf_strings/ir:dialect",
- "//iree_tf_compiler/dialect/tf_strings/ir:ops",
- "//iree_tf_compiler/dialect/utils:conversion_utils",
- "@iree//iree/compiler/Dialect/Modules/Strings/IR",
- "@iree//iree/compiler/Dialect/Modules/Strings/IR:Dialect",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:Support",
- "@llvm-project//mlir:Transforms",
- ],
-)
-
-gentbl_cc_library(
- name = "convert_tf_to_tf_strings_rewriter_gen",
- tbl_outs = [
- (
- ["-gen-rewriters"],
- "convert_tf_to_tf_strings.inc",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "convert_tf_to_tf_strings.td",
- td_includes = ["external/org_tensorflow"],
- td_srcs = [
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow:tensorflow_ops_td_files",
- "//iree_tf_compiler/dialect/tf_strings/ir:td_files",
- "@llvm-project//mlir:StdOpsTdFiles",
- "@llvm-project//mlir:include/mlir/Interfaces/InferTypeOpInterface.td",
- ],
-)
-
-cc_library(
- name = "convert_tf_to_tf_strings",
- srcs = [
- "convert_tf_to_tf_strings.cc",
- ],
- hdrs = [
- "convert_tf_to_tf_strings.h",
- ],
- deps = [
- ":convert_tf_to_tf_strings_rewriter_gen",
- "//iree_tf_compiler/dialect/tf_strings/ir",
- "//iree_tf_compiler/dialect/tf_strings/ir:dialect",
- "//iree_tf_compiler/dialect/tf_strings/ir:ops",
- "//iree_tf_compiler/dialect/utils:conversion_utils",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:Support",
- "@llvm-project//mlir:Transforms",
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow",
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow:tensorflow_types",
- ],
-)
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_strings_to_strings.cc b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_strings_to_strings.cc
deleted file mode 100644
index 23455cd..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_strings_to_strings.cc
+++ /dev/null
@@ -1,97 +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
-
-#include "iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_strings_to_strings.h"
-
-#include "iree/compiler/Dialect/Modules/Strings/IR/Dialect.h"
-#include "iree/compiler/Dialect/Modules/Strings/IR/Ops.h"
-#include "iree_tf_compiler/dialect/tf_strings/ir/dialect.h"
-#include "iree_tf_compiler/dialect/tf_strings/ir/ops.h"
-#include "iree_tf_compiler/dialect/tf_strings/ir/types.h"
-#include "iree_tf_compiler/dialect/utils/conversion_utils.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/PatternMatch.h"
-#include "mlir/Pass/Pass.h"
-#include "mlir/Pass/PassRegistry.h"
-#include "mlir/Support/LogicalResult.h"
-#include "mlir/Transforms/DialectConversion.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_strings {
-
-namespace {
-
-class StringTypeConverter : public TypeConverter {
- public:
- StringTypeConverter() {
- // Required to covert any unknown or already converted types.
- addConversion([](Type type) { return type; });
- addConversion([](tf_strings::StringType type) {
- return iree_compiler::IREE::Strings::StringType::get(type.getContext());
- });
- addConversion([](TensorType type) -> Type {
- if (type.getElementType().isa<tf_strings::StringType>()) {
- return iree_compiler::IREE::Strings::StringTensorType::get(
- type.getContext());
- }
- return type;
- });
- }
-};
-
-class ConvertTFStringsToStringsPass
- : public ConversionPass<ConvertTFStringsToStringsPass,
- StringTypeConverter> {
- public:
- void getDependentDialects(DialectRegistry ®istry) const override {
- registry
- .insert<TFStringsDialect, iree_compiler::IREE::Strings::StringsDialect,
- StandardOpsDialect>();
- }
-
- void Setup(ConversionTarget &target,
- OwningRewritePatternList &patterns) override {
- target.addIllegalDialect<tf_strings::TFStringsDialect>();
- target.addLegalDialect<iree_compiler::IREE::Strings::StringsDialect>();
- populateTFStringsToStringsPatterns(&this->getContext(), patterns);
- }
-};
-} // namespace
-
-void populateTFStringsToStringsPatterns(MLIRContext *context,
- OwningRewritePatternList &patterns) {
- patterns.insert<
- OpConversion<tf_strings::PrintOp, iree_compiler::IREE::Strings::PrintOp>>(
- context);
- patterns.insert<OpConversion<tf_strings::ToStringTensorOp,
- iree_compiler::IREE::Strings::ToStringTensorOp>>(
- context);
- patterns.insert<OpConversion<tf_strings::GatherOp,
- iree_compiler::IREE::Strings::GatherOp>>(
- context);
- patterns.insert<
- OpConversion<tf_strings::StringTensorToStringOp,
- iree_compiler::IREE::Strings::StringTensorToStringOp>>(
- context);
- patterns.insert<OpConversion<tf_strings::ToStringOp,
- iree_compiler::IREE::Strings::I32ToStringOp>>(
- context);
-}
-
-std::unique_ptr<OperationPass<ModuleOp>> createConvertTFStringsToStringsPass() {
- return std::make_unique<ConvertTFStringsToStringsPass>();
-}
-
-static PassRegistration<ConvertTFStringsToStringsPass> pass(
- "iree-tf-strings-convert-to-strings",
- "Converts TF string ops to the IREE tf_strings dialect");
-
-} // namespace tf_strings
-} // namespace iree_integrations
-} // namespace mlir
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_strings_to_strings.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_strings_to_strings.h
deleted file mode 100644
index a29cbde..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_strings_to_strings.h
+++ /dev/null
@@ -1,32 +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
-
-#ifndef IREE_INTEGRATIONS_TFSTRINGS_CONVERSION_CONVERT_TF_STRINGS_TO_STRINGS_H_
-#define IREE_INTEGRATIONS_TFSTRINGS_CONVERSION_CONVERT_TF_STRINGS_TO_STRINGS_H_
-
-#include "iree/compiler/Dialect/Modules/Strings/IR/Dialect.h"
-#include "iree/compiler/Dialect/Modules/Strings/IR/Types.h"
-#include "iree_tf_compiler/dialect/tf_strings/ir/types.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/TypeUtilities.h"
-#include "mlir/Pass/Pass.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_strings {
-
-std::unique_ptr<OperationPass<ModuleOp>> createConvertTFStringsToStringsPass();
-
-// Populates conversion patterns from the tensor-based custom dialect ops to the
-// HAL buffer-based ones.
-void populateTFStringsToStringsPatterns(MLIRContext *context,
- OwningRewritePatternList &patterns);
-
-} // namespace tf_strings
-} // namespace iree_integrations
-} // namespace mlir
-
-#endif // IREE_INTEGRATIONS_TFSTRINGS_TRANSFORMS_TFSTRINGSTOSTRINGS_H_
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.cc b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.cc
deleted file mode 100644
index 1108cb4..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.cc
+++ /dev/null
@@ -1,156 +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
-
-#include "iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.h"
-
-#include <cstddef>
-
-#include "iree_tf_compiler/dialect/tf_strings/ir/dialect.h"
-#include "iree_tf_compiler/dialect/tf_strings/ir/ops.h"
-#include "iree_tf_compiler/dialect/tf_strings/ir/types.h"
-#include "iree_tf_compiler/dialect/utils/conversion_utils.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/Matchers.h"
-#include "mlir/IR/PatternMatch.h"
-#include "mlir/Pass/Pass.h"
-#include "mlir/Pass/PassRegistry.h"
-#include "mlir/Support/LogicalResult.h"
-#include "mlir/Transforms/DialectConversion.h"
-#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"
-#include "tensorflow/compiler/mlir/tensorflow/ir/tf_types.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_strings {
-
-namespace {
-
-#include "iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.inc"
-
-class StringTypeConverter : public TypeConverter {
- public:
- StringTypeConverter() {
- // Required to covert any unknown or already converted types.
- addConversion([](Type type) { return type; });
- addConversion([](RankedTensorType type) -> Type {
- if (type.getElementType().isa<TF::StringType>()) {
- auto elementType = tf_strings::StringType::get(type.getContext());
- // TODO(suderman): Find a better way to identify tensor<!tf.string> and
- // !tf.string.
- // Tensorflow only operates on tensors, so "scalar" strings are actually
- // rank-0 tensors of strings. For now separate operating on tensors of
- // strings and scalar strings by forcing all rank-0 tensors of strings
- // to strings.
- if (type.getRank() == 0) {
- return tf_strings::StringType::get(type.getContext());
- }
- return RankedTensorType::get(type.getShape(), elementType);
- }
-
- return type;
- });
- addConversion([](TF::StringType type) {
- return tf_strings::StringType::get(type.getContext());
- });
- }
-};
-
-struct StringFormatOpLowering : public OpRewritePattern<TF::StringFormatOp> {
- using OpRewritePattern<TF::StringFormatOp>::OpRewritePattern;
-
- LogicalResult matchAndRewrite(TF::StringFormatOp op,
- PatternRewriter &rewriter) const override {
- auto inputs = op.inputs();
- // TODO(suderman): Implement a variadic version. For now assume one input.
- if (inputs.size() != 1)
- return rewriter.notifyMatchFailure(op,
- "Variadic StringFormat unsupported.");
-
- auto input = inputs[0];
-
- rewriter.replaceOpWithNewOp<tf_strings::StringTensorToStringOp>(op, input);
- return success();
- }
-};
-
-struct GatherV2OpLowering : public OpRewritePattern<TF::GatherV2Op> {
- using OpRewritePattern<TF::GatherV2Op>::OpRewritePattern;
-
- LogicalResult matchAndRewrite(TF::GatherV2Op op,
- PatternRewriter &rewriter) const override {
- auto tensor = op.params();
- auto tensorTy = tensor.getType().dyn_cast<RankedTensorType>();
- if (!tensorTy || !tensorTy.getElementType().isa<TF::StringType>()) {
- return failure();
- }
-
- DenseIntElementsAttr axis;
- if (!matchPattern(op.axis(), m_Constant(&axis))) {
- return failure();
- }
-
- if (axis.getType().cast<ShapedType>().getRank() != 0) {
- return failure();
- }
-
- auto axisValue = axis.getValue<IntegerAttr>({});
- auto axisInt = axisValue.getValue().getZExtValue();
-
- if (axisInt != tensorTy.getRank() - 1) {
- return failure();
- }
-
- auto resultTy = op.getType().cast<ShapedType>();
- rewriter.replaceOpWithNewOp<tf_strings::GatherOp>(
- op,
- RankedTensorType::get(resultTy.getShape(),
- tf_strings::StringType::get(op.getContext())),
- tensor, op.indices());
-
- return success();
- }
-};
-
-class ConvertTFToTFStringsPass
- : public ConversionPass<ConvertTFToTFStringsPass, StringTypeConverter> {
- public:
- void getDependentDialects(DialectRegistry ®istry) const override {
- registry.insert<mlir::TF::TensorFlowDialect, TFStringsDialect,
- StandardOpsDialect>();
- }
-
- void Setup(ConversionTarget &target,
- OwningRewritePatternList &patterns) override {
- target.addIllegalOp<TF::AsStringOp>();
- target.addIllegalOp<TF::PrintV2Op>();
- target.addLegalDialect<tf_strings::TFStringsDialect>();
-
- populateTFToTFStringsPatterns(&this->getContext(), patterns);
- }
-};
-
-} // namespace
-
-void populateTFToTFStringsPatterns(MLIRContext *ctx,
- OwningRewritePatternList &patterns) {
- populateWithGenerated(patterns);
- patterns.insert<GatherV2OpLowering>(ctx);
- patterns.insert<StringFormatOpLowering>(ctx);
-}
-
-std::unique_ptr<OperationPass<ModuleOp>> createConvertTFToTFStringsPass() {
- return std::make_unique<ConvertTFToTFStringsPass>();
-}
-
-static PassRegistration<ConvertTFToTFStringsPass> pass(
- "iree-tf-convert-to-tf-strings",
- "Converts TF string ops to the IREE tf_strings dialect");
-
-} // namespace tf_strings
-} // namespace iree_integrations
-} // namespace mlir
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.h
deleted file mode 100644
index de0232d..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.h
+++ /dev/null
@@ -1,28 +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
-
-#ifndef IREE_INTEGRATIONS_TFSTRINGS_CONVERSION_TFTOTFSTRINGSS_H_
-#define IREE_INTEGRATIONS_TFSTRINGS_CONVERSION_TFTOTFSTRINGSS_H_
-
-#include "mlir/IR/MLIRContext.h"
-#include "mlir/IR/PatternMatch.h"
-#include "mlir/Pass/Pass.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_strings {
-
-std::unique_ptr<OperationPass<ModuleOp>> createConvertTFToTFStringsPass();
-
-// Adds rewrite patterns for lowering tensorflow operations to tf_strings.
-void populateTFToTFStringsPatterns(MLIRContext *ctx,
- OwningRewritePatternList &patterns);
-
-} // namespace tf_strings
-} // namespace iree_integrations
-} // namespace mlir
-
-#endif // IREE_INTEGRATIONS_TFSTRINGS_TRANSFORMS_TFSTRINGSTOSTRINGS_H_
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.td b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.td
deleted file mode 100644
index 5d59721..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/convert_tf_to_tf_strings.td
+++ /dev/null
@@ -1,22 +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
-
-include "mlir/IR/OpBase.td"
-include "mlir/Dialect/StandardOps/IR/Ops.td"
-include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.td"
-include "iree_tf_compiler/dialect/tf_strings/ir/ops.td"
-
-def : Pat<(TF_IdentityOp TF_StrTensor:$value),
- (replaceWithValue $value)>;
-
-def : Pat<(TF_PrintV2Op TF_Str:$value, $unused1, $unused2),
- (TFStrings_PrintOp $value)>;
-
-def : Pat<(TF_PrintV2Op TF_StrTensor:$value, $unused1, $unused2),
- (TFStrings_PrintOp $value)>;
-
-def : Pat<(TF_AsStringOp $value, $u1, $u2, $u3, $u4, $u5),
- (TFStrings_ToStringTensorOp $value)>;
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/test/BUILD b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/test/BUILD
deleted file mode 100644
index 01bacd1..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/test/BUILD
+++ /dev/null
@@ -1,32 +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
-
-# Tests for lowering MLIR in various dialects to IREE interpreter bytecode.
-
-load("@iree//iree:lit_test.bzl", "iree_lit_test_suite")
-load("@iree//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(
- [
- "tf_strings_to_strings.mlir",
- "tf_to_tf_strings.mlir",
- ],
- include = ["*.mlir"],
- ),
- data = [
- "//iree_tf_compiler:iree-tf-opt",
- "@iree//iree/tools:IreeFileCheck",
- ],
- driver = "@iree//iree/tools:run_lit.sh",
-)
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/test/tf_strings_to_strings.mlir b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/test/tf_strings_to_strings.mlir
deleted file mode 100644
index a220ae3..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/test/tf_strings_to_strings.mlir
+++ /dev/null
@@ -1,46 +0,0 @@
-// RUN: iree-tf-opt --iree-tf-strings-convert-to-strings %s --split-input-file | IreeFileCheck %s
-
-// CHECK-LABEL: @i32_to_string
-func @i32_to_string(%arg0 : i32) -> !tf_strings.string {
- // CHECK-DAG: [[VAL0:%.+]] = "strings.i32_to_string"(%arg0)
- %0 = "tf_strings.to_string"(%arg0) : (i32) -> (!tf_strings.string)
-
- // CHECK: return [[VAL0]]
- return %0 : !tf_strings.string
-}
-
-// CHECK-LABEL: @print_string
-func @print_string(%arg0 : !tf_strings.string) {
- // CHECK-DAG: "strings.print"(%arg0)
- "tf_strings.print"(%arg0) : (!tf_strings.string) -> ()
-
- // CHECK: return
- return
-}
-
-// CHECK-LABEL: @to_string_tensor.f32
-func @to_string_tensor.f32(%arg0 : tensor<5xf32>) -> tensor<5x!tf_strings.string> {
- // CHECK-DAG: [[VAL0:%.+]] = "strings.to_string_tensor"(%arg0)
- %0 = "tf_strings.to_string_tensor"(%arg0) : (tensor<5xf32>) -> tensor<5x!tf_strings.string>
-
- // CHECK: return [[VAL0]]
- return %0 : tensor<5x!tf_strings.string>
-}
-
-// CHECK-LABEL: @string_tensor_to_string
-func @string_tensor_to_string(%arg0 : tensor<!tf_strings.string>) -> !tf_strings.string {
- // CHECK-DAG: [[VAL0:%.+]] = "strings.string_tensor_to_string"(%arg0)
- %0 = "tf_strings.string_tensor_to_string"(%arg0) : (tensor<!tf_strings.string>) -> (!tf_strings.string)
-
- // CHECK: return [[VAL0]]
- return %0 : !tf_strings.string
-}
-
-// CHECK-LABEL: @gather
-func @gather(%arg0: tensor<5x!tf_strings.string>, %arg1: tensor<3xi32>) -> tensor<3x!tf_strings.string> {
- // CHECK-DAG: [[VAL0:%.+]] = "strings.gather"(%arg0, %arg1)
- %0 = "tf_strings.gather"(%arg0, %arg1) : (tensor<5x!tf_strings.string>, tensor<3xi32>) -> tensor<3x!tf_strings.string>
-
- // CHECK: return [[VAL0]]
- return %0 : tensor<3x!tf_strings.string>
-}
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/test/tf_to_tf_strings.mlir b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/test/tf_to_tf_strings.mlir
deleted file mode 100644
index eb42d54..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/conversion/test/tf_to_tf_strings.mlir
+++ /dev/null
@@ -1,46 +0,0 @@
-// RUN: iree-tf-opt --iree-tf-convert-to-tf-strings %s --split-input-file | IreeFileCheck %s
-
-// CHECK-LABEL: func @as_string.tensor.f32
-func @as_string.tensor.f32(%arg0: tensor<5xf32>) -> tensor<5x!tf.string> {
- // CHECK-DAG: [[VAL0:%.+]] = "tf_strings.to_string_tensor"(%arg0)
- %0 = "tf.AsString"(%arg0) {fill = ""} : (tensor<5xf32>) -> tensor<5x!tf.string>
- // CHECK: return [[VAL0]]
- return %0 : tensor<5x!tf.string>
-}
-
-// CHECK-LABEL: func @string_tensor_to_string
-func @string_tensor_to_string(%arg0: tensor<5x!tf.string>) -> tensor<!tf.string> {
- // CHECK-DAG: [[VAL0:%.+]] = "tf_strings.string_tensor_to_string"(%arg0)
- %0 = "tf.StringFormat"(%arg0) : (tensor<5x!tf.string>) -> tensor<!tf.string>
- // CHECK: return [[VAL0]] : !tf_strings.string
- return %0 : tensor<!tf.string>
-}
-
-// CHECK-LABEL: func @printv2.tensor.string
-func @printv2.tensor.string(%arg0: tensor<5x!tf.string>) {
- // CHECK-DAG: [[VAL0:%.+]] = "tf_strings.string_tensor_to_string"(%arg0)
- %0 = "tf.StringFormat"(%arg0) : (tensor<5x!tf.string>) -> tensor<!tf.string>
- // CHECK: tf_strings.print"([[VAL0]])
- "tf.PrintV2"(%0) {_output_shapes = [], device = "", end = "\0A", output_stream = "stderr"} : (tensor<!tf.string>) -> ()
- return
-}
-
-// CHECK-LABEL: func @printv2.tensor.f32
-func @printv2.tensor.f32(%arg0: tensor<5xf32>) {
- // CHECK-NEXT: [[VAL0:%.+]] = "tf_strings.to_string_tensor"(%arg0)
- // CHECK-DAG: [[VAL1:%.+]] = "tf_strings.string_tensor_to_string"([[VAL0]])
- // CHECK: "tf_strings.print"([[VAL1]])
- %0 = "tf.AsString"(%arg0) {fill = ""} : (tensor<5xf32>) -> tensor<5x!tf.string>
- %1 = "tf.StringFormat"(%0) : (tensor<5x!tf.string>) -> tensor<!tf.string>
- "tf.PrintV2"(%1) {_output_shapes = [], device = "", end = "\0A", output_stream = "stderr"} : (tensor<!tf.string>) -> ()
- return
-}
-
-// CHECK-LABEL: func @gatherv2
-func @gatherv2(%arg0: tensor<5x!tf.string>, %arg1: tensor<3xi32>) {
- %0 = "tf.Const"() {device = "", value = dense<0> : tensor<i32>} : () -> tensor<i32>
-
- // CHECK-DAG: [[VAL0:%.+]] = "tf_strings.gather"(%arg0, %arg1)
- %1 = "tf.GatherV2"(%arg0, %arg1, %0) {batch_dims = 0 : i64, device = ""} : (tensor<5x!tf.string>, tensor<3xi32>, tensor<i32>) -> tensor<3x!tf.string>
- return
-}
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/BUILD b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/BUILD
deleted file mode 100644
index 346b24c..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/BUILD
+++ /dev/null
@@ -1,111 +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
-
-load("@iree//build_tools/bazel:tblgen.bzl", "gentbl_cc_library")
-load("@iree//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-filegroup(
- name = "td_files",
- srcs = enforce_glob(
- [
- "base.td",
- "ops.td",
- ],
- include = ["*.td"],
- ),
-)
-
-gentbl_cc_library(
- name = "ops_gen",
- tbl_outs = [
- (
- ["-gen-op-decls"],
- "ops.h.inc",
- ),
- (
- ["-gen-op-defs"],
- "ops.cpp.inc",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "ops.td",
- td_includes = ["external/org_tensorflow"],
- td_srcs = [
- ":td_files",
- "@llvm-project//mlir:OpBaseTdFiles",
- ],
-)
-
-gentbl_cc_library(
- name = "op_interface_gen",
- tbl_outs = [
- (
- ["-gen-op-interface-decls"],
- "op_interface.h.inc",
- ),
- (
- ["-gen-op-interface-defs"],
- "op_interface.cpp.inc",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "base.td",
- td_includes = ["external/org_tensorflow"],
- td_srcs = [
- ":td_files",
- "@llvm-project//mlir:OpBaseTdFiles",
- ],
-)
-
-cc_library(
- name = "ir",
- deps = [
- ":dialect",
- ":ops",
- ],
-)
-
-cc_library(
- name = "dialect",
- srcs = [
- "dialect.cpp",
- ],
- hdrs = [
- "dialect.h",
- ],
- deps = [
- ":op_interface_gen",
- ":ops",
- ":ops_gen",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- ],
-)
-
-cc_library(
- name = "ops",
- srcs = [
- "ops.cpp",
- "ops.cpp.inc",
- ],
- hdrs = [
- "ops.h",
- "ops.h.inc",
- "types.h",
- ],
- deps = [
- ":op_interface_gen",
- ":ops_gen",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- ],
-)
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/base.td b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/base.td
deleted file mode 100644
index 050b465..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/base.td
+++ /dev/null
@@ -1,46 +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
-
-#ifndef STRINGS_BASE
-#define STRINGS_BASE
-
-include "mlir/IR/OpBase.td"
-
-//===----------------------------------------------------------------------===//
-// IREE execution flow dialect
-//===----------------------------------------------------------------------===//
-
-def TFStrings_Dialect : Dialect {
- let name = "tf_strings";
- let cppNamespace = "::mlir::iree_integrations::tf_strings";
- let summary = [{
- A strings dialect for simplifying tensorflow string operations.
- }];
- let description = [{
- A strings dialect for simplifying tensorflow string operations.
- }];
-
-}
-
-def TFStrings_String : DialectType<
- TFStrings_Dialect,
- CPred<"$_self.isa<tf_strings::StringType>()">,
- "string"> {
- let description = [{
- String type representation.
- }];
-}
-
-class TFStrings_Op<string mnemonic, list<OpTrait> traits = []> :
- Op<TFStrings_Dialect, mnemonic, traits> {
-}
-
-
-def TFStrings_Value : AnyTypeOf<[AnyFloat, AnySignlessInteger]>;
-def TFStrings_StringTensor : TensorOf<[TFStrings_String]>;
-def TFStrings_ValueTensor : TensorOf<[AnyFloat, AnySignlessInteger]>;
-
-#endif // STRINGS_BASE
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/dialect.cpp b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/dialect.cpp
deleted file mode 100644
index ebe8ed7..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/dialect.cpp
+++ /dev/null
@@ -1,55 +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
-
-#include "iree_tf_compiler/dialect/tf_strings/ir/dialect.h"
-
-#include "iree_tf_compiler/dialect/tf_strings/ir/ops.h"
-#include "iree_tf_compiler/dialect/tf_strings/ir/types.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "mlir/IR/Attributes.h"
-#include "mlir/IR/DialectImplementation.h"
-#include "mlir/IR/OpImplementation.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_strings {
-
-#include "iree_tf_compiler/dialect/tf_strings/ir/op_interface.cpp.inc"
-
-TFStringsDialect::TFStringsDialect(MLIRContext* context)
- : Dialect(getDialectNamespace(), context, TypeID::get<TFStringsDialect>()) {
- addTypes<StringType>();
-
-#define GET_OP_LIST
- addOperations<
-#include "iree_tf_compiler/dialect/tf_strings/ir/ops.cpp.inc"
- >();
-}
-
-Type TFStringsDialect::parseType(DialectAsmParser& parser) const {
- Location loc = parser.getEncodedSourceLoc(parser.getNameLoc());
- llvm::StringRef spec = parser.getFullSymbolSpec();
- if (spec == "string") {
- return StringType::get(getContext());
- }
- emitError(loc, "unknown TFStrings type: ") << spec;
- return Type();
-}
-
-void TFStringsDialect::printType(Type type, DialectAsmPrinter& os) const {
- if (type.isa<tf_strings::StringType>())
- os << "string";
- else
- llvm_unreachable("unhandled string type");
-}
-
-bool TFStringsType::classof(Type type) {
- return llvm::isa<TFStringsDialect>(type.getDialect());
-}
-
-} // namespace tf_strings
-} // namespace iree_integrations
-} // namespace mlir
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/dialect.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/dialect.h
deleted file mode 100644
index eefeb30..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/dialect.h
+++ /dev/null
@@ -1,34 +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
-
-#ifndef INTEGRATIONS_TENSORFLOW_COMPILER_DIALECT_TFSTRINGS_IR_DIALECT_H_
-#define INTEGRATIONS_TENSORFLOW_COMPILER_DIALECT_TFSTRINGS_IR_DIALECT_H_
-
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/OpDefinition.h"
-#include "mlir/IR/SymbolTable.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_strings {
-
-#include "iree_tf_compiler/dialect/tf_strings/ir/op_interface.h.inc"
-
-class TFStringsDialect : public Dialect {
- public:
- explicit TFStringsDialect(MLIRContext* context);
- static StringRef getDialectNamespace() { return "tf_strings"; }
-
- Type parseType(DialectAsmParser& parser) const override;
-
- void printType(Type type, DialectAsmPrinter& os) const override;
-};
-
-} // namespace tf_strings
-} // namespace iree_integrations
-} // namespace mlir
-
-#endif // INTEGRATIONS_TENSORFLOW_COMPILER_DIALECT_TFSTRINGS_IR_DIALECT_H_
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/ops.cpp b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/ops.cpp
deleted file mode 100644
index 2611185..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/ops.cpp
+++ /dev/null
@@ -1,50 +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
-
-// IREE ops for working with buffers and buffer views.
-// These are used by common transforms between the sequencer and interpreter and
-// allow us to share some of the common lowering passes from other dialects.
-
-#include "iree_tf_compiler/dialect/tf_strings/ir/ops.h"
-
-#include "iree_tf_compiler/dialect/tf_strings/ir/types.h"
-#include "mlir/IR/Builders.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/PatternMatch.h"
-
-#define GET_OP_CLASSES
-#include "iree_tf_compiler/dialect/tf_strings/ir/ops.cpp.inc"
-#undef GET_OP_CLASSES
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_strings {
-
-void ToStringOp::build(OpBuilder& builder, OperationState& tblgen_state,
- Value value) {
- build(builder, tblgen_state, StringType::get(builder.getContext()), value);
-}
-
-void ToStringTensorOp::build(OpBuilder& builder, OperationState& tblgen_state,
- Value value) {
- if (auto type = value.getType().dyn_cast<ShapedType>()) {
- auto new_type = RankedTensorType::get(
- type.getShape(), StringType::get(builder.getContext()));
- build(builder, tblgen_state, new_type, value);
- return;
- }
- llvm_unreachable("Invalid input to ToStringTensorOp");
-}
-
-void StringTensorToStringOp::build(OpBuilder& builder,
- OperationState& tblgen_state, Value value) {
- build(builder, tblgen_state, StringType::get(builder.getContext()), value);
-}
-
-} // namespace tf_strings
-} // namespace iree_integrations
-} // namespace mlir
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/ops.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/ops.h
deleted file mode 100644
index 91a6513..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/ops.h
+++ /dev/null
@@ -1,28 +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
-
-// IREE ops for working with buffers and buffer views.
-// These are used by common transforms between the sequencer and interpreter and
-// allow us to share some of the common lowering passes from other dialects.
-
-#ifndef INTEGRATIONS_TENSORFLOW_COMPILER_DIALECT_TFSTRINGS_IR_OPS_H_
-#define INTEGRATIONS_TENSORFLOW_COMPILER_DIALECT_TFSTRINGS_IR_OPS_H_
-
-#include "mlir/IR/Attributes.h"
-#include "mlir/IR/Builders.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/Matchers.h"
-#include "mlir/IR/OpImplementation.h"
-#include "mlir/IR/TypeUtilities.h"
-#include "mlir/Interfaces/CallInterfaces.h"
-
-#define GET_OP_CLASSES
-#include "iree_tf_compiler/dialect/tf_strings/ir/ops.h.inc"
-#undef GET_OP_CLASSES
-
-#endif // INTEGRATIONS_TENSORFLOW_COMPILER_DIALECT_TFSTRINGS_IR_OPS_H_
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/ops.td b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/ops.td
deleted file mode 100644
index 9afffea..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/ops.td
+++ /dev/null
@@ -1,89 +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
-
-// Common IREE op definitions shared by the interpreter and sequencer dialects.
-
-#ifndef TFSTRINGS
-#define TFSTRINGS
-
-include "mlir/IR/OpBase.td"
-include "iree_tf_compiler/dialect/tf_strings/ir/base.td"
-
-//===----------------------------------------------------------------------===//
-// TFStrings dialect used for intermediate manipulations.
-//===----------------------------------------------------------------------===//
-
-def TFStrings_PrintOp : TFStrings_Op<"print"> {
- let summary = "Prints the string to standard output.";
- let description = [{
- Prints the contents of a passed tensor.
- }];
- let arguments = (ins TFStrings_String:$arguments);
- let results = (outs);
-}
-
-def TFStrings_ToStringOp : TFStrings_Op<"to_string"> {
- let summary = "Converts the value to a string.";
- let description = [{
- Converts the value to a string.
- }];
- let arguments = (ins TFStrings_Value: $arguments);
- let results = (outs TFStrings_String: $result);
- let builders = [
- OpBuilder<(ins "Value":$value)>];
-}
-
-def TFStrings_GatherOp : Op<TFStrings_Dialect, "gather"> {
- let summary = "Gathers all the strings from by index.";
- let description = [{
- Gathers all the strings from a Tensor using the index of the last dimension.
- }];
-
- let arguments = (ins TFStrings_StringTensor:$dict,
- TFStrings_ValueTensor:$indices);
-
- let results = (outs
- TFStrings_StringTensor:$result
- );
-}
-
-def TFStrings_ConcatOp : Op<TFStrings_Dialect, "concat"> {
- let summary = "Concatenates the strings in the tensor along the last dimension.";
-
- let description = [{
- Concatenates the strings in the tensor along the last dimension.
- }];
-
- let arguments = (ins TFStrings_StringTensor:$value);
-
- let results = (outs
- TFStrings_StringTensor:$result
- );
-}
-
-def TFStrings_ToStringTensorOp : TFStrings_Op<"to_string_tensor"> {
- let summary = "Converts a tensor of values to a tensor of strings.";
- let description = [{
- Converts a tensor of values to a tensor of strings.
- }];
- let arguments = (ins TFStrings_ValueTensor: $arguments);
- let results = (outs TFStrings_StringTensor: $result);
- let builders = [
- OpBuilder<(ins "Value":$value)>];
-}
-
-def TFStrings_StringTensorToStringOp : TFStrings_Op<"string_tensor_to_string"> {
- let summary = "Converts a string tensor to a string.";
- let description = [{
- Converts a tensor of strings to a string.
- }];
- let arguments = (ins TFStrings_StringTensor: $arguments);
- let results = (outs TFStrings_String: $result);
- let builders = [
- OpBuilder<(ins "Value":$value)>];
-}
-
-#endif // TFSTRINGS
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/types.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/types.h
deleted file mode 100644
index bdc43fc..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_strings/ir/types.h
+++ /dev/null
@@ -1,41 +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
-
-// IREE ops for working with buffers and buffer views.
-// These are used by common transforms between the sequencer and interpreter and
-// allow us to share some of the common lowering passes from other dialects.
-
-#ifndef INTEGRATIONS_TENSORFLOW_COMPILER_DIALECT_TFSTRINGS_IR_TYPES_H_
-#define INTEGRATIONS_TENSORFLOW_COMPILER_DIALECT_TFSTRINGS_IR_TYPES_H_
-
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Diagnostics.h"
-#include "mlir/IR/Location.h"
-#include "mlir/IR/StorageUniquerSupport.h"
-#include "mlir/IR/Types.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_strings {
-
-class TFStringsType : public Type {
- public:
- using Type::Type;
-
- static bool classof(Type type);
-};
-
-class StringType
- : public Type::TypeBase<StringType, TFStringsType, TypeStorage> {
- public:
- using Base::Base;
-};
-
-} // namespace tf_strings
-} // namespace iree_integrations
-} // namespace mlir
-
-#endif // INTEGRATIONS_TENSORFLOW_COMPILER_DIALECT_TFSTRINGS_IR_TYPES_H_
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/BUILD b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/BUILD
deleted file mode 100644
index 77c80d4..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/BUILD
+++ /dev/null
@@ -1,75 +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("@iree//build_tools/bazel:tblgen.bzl", "gentbl_cc_library")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-cc_library(
- name = "convert_tf_to_tf_tensorlist",
- srcs = [
- "convert_tf_to_tf_tensorlist.cc",
- ],
- hdrs = [
- "convert_tf_to_tf_tensorlist.h",
- ],
- deps = [
- ":convert_tf_to_tf_tensorlist_rewriter_gen",
- "//iree_tf_compiler/dialect/tf_tensorlist/ir:tf_tensorlist_dialect",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:StandardOps",
- "@llvm-project//mlir:Transforms",
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow",
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow:tensorflow_types",
- ],
-)
-
-gentbl_cc_library(
- name = "convert_tf_to_tf_tensorlist_rewriter_gen",
- tbl_outs = [
- (
- ["-gen-rewriters"],
- "convert_tf_to_tf_tensorlist.inc",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "convert_tf_to_tf_tensorlist.td",
- td_includes = ["external/org_tensorflow"],
- td_srcs = [
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow:tensorflow_ops_td_files",
- "//iree_tf_compiler/dialect/tf_tensorlist/ir:td_files",
- "@llvm-project//mlir:StdOpsTdFiles",
- "@iree//iree/compiler/Dialect/IREE/IR:td_files",
- "@llvm-project//mlir:include/mlir/Interfaces/InferTypeOpInterface.td",
- ],
-)
-
-cc_library(
- name = "convert_tf_tensorlist_to_tensorlist",
- srcs = [
- "convert_tf_tensorlist_to_tensorlist.cc",
- ],
- hdrs = [
- "convert_tf_tensorlist_to_tensorlist.h",
- ],
- deps = [
- "//iree_tf_compiler/dialect/tf_tensorlist/ir",
- "//iree_tf_compiler/dialect/tf_tensorlist/ir:tf_tensorlist_dialect",
- "//iree_tf_compiler/dialect/utils:conversion_utils",
- "@iree//iree/compiler/Dialect/Modules/TensorList/IR",
- "@iree//iree/compiler/Dialect/Modules/TensorList/IR:TensorListDialect",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:Support",
- "@llvm-project//mlir:Transforms",
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow",
- ],
-)
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_tensorlist_to_tensorlist.cc b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_tensorlist_to_tensorlist.cc
deleted file mode 100644
index 292741a..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_tensorlist_to_tensorlist.cc
+++ /dev/null
@@ -1,100 +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
-
-#include "iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_tensorlist_to_tensorlist.h"
-
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.h"
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.h"
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.h"
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.h"
-#include "iree_tf_compiler/dialect/utils/conversion_utils.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/PatternMatch.h"
-#include "mlir/Pass/PassRegistry.h"
-#include "mlir/Support/LogicalResult.h"
-#include "mlir/Transforms/DialectConversion.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_tensorlist {
-
-namespace {
-
-class TensorListTypeConverter : public TypeConverter {
- public:
- TensorListTypeConverter() {
- // Required to covert any unknown or already converted types.
- addConversion([](Type type) { return type; });
- addConversion([](tf_tensorlist::TensorListType type) {
- return iree_compiler::IREE::TensorList::TensorListType::get(
- type.getContext());
- });
- }
-};
-
-// Populates conversion patterns from the tensor-based custom dialect ops to the
-// HAL buffer-based ones.
-void populateTensorListToHALPatterns(MLIRContext *context,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter);
-
-void populateTFTensorListToTensorListPatterns(
- MLIRContext *context, OwningRewritePatternList &patterns) {
- patterns.insert<OpConversion<tf_tensorlist::Reserve,
- iree_compiler::IREE::TensorList::ReserveTensor>>(
- context);
- patterns.insert<OpConversion<tf_tensorlist::GetItem,
- iree_compiler::IREE::TensorList::GetItem>>(
- context);
- patterns.insert<OpConversion<tf_tensorlist::SetItem,
- iree_compiler::IREE::TensorList::SetItem>>(
- context);
- patterns.insert<OpConversion<tf_tensorlist::FromTensor,
- iree_compiler::IREE::TensorList::FromTensor>>(
- context);
- patterns.insert<OpConversion<tf_tensorlist::Concat,
- iree_compiler::IREE::TensorList::ConcatTensor>>(
- context);
- patterns.insert<OpConversion<tf_tensorlist::Stack,
- iree_compiler::IREE::TensorList::StackTensor>>(
- context);
-}
-
-class ConvertTFTensorlistToTensorlistPass
- : public ConversionPass<ConvertTFTensorlistToTensorlistPass,
- TensorListTypeConverter> {
- public:
- void getDependentDialects(DialectRegistry ®istry) const override {
- registry.insert<tf_tensorlist::TFTensorListDialect,
- iree_compiler::IREE::TensorList::TensorListDialect,
- StandardOpsDialect>();
- }
-
- void Setup(ConversionTarget &target,
- OwningRewritePatternList &patterns) override {
- target.addIllegalDialect<tf_tensorlist::TFTensorListDialect>();
- target
- .addLegalDialect<iree_compiler::IREE::TensorList::TensorListDialect>();
- populateTFTensorListToTensorListPatterns(&this->getContext(), patterns);
- }
-};
-
-} // namespace
-
-std::unique_ptr<OperationPass<ModuleOp>>
-createConvertTFTensorListToTensorListPass() {
- return std::make_unique<ConvertTFTensorlistToTensorlistPass>();
-}
-
-static PassRegistration<ConvertTFTensorlistToTensorlistPass> pass(
- "iree-tf-tensorlist-convert-to-tensorlist",
- "Converts TF string ops to the IREE tf_strings dialect");
-
-} // namespace tf_tensorlist
-} // namespace iree_integrations
-} // namespace mlir
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_tensorlist_to_tensorlist.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_tensorlist_to_tensorlist.h
deleted file mode 100644
index bf90a77..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_tensorlist_to_tensorlist.h
+++ /dev/null
@@ -1,28 +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
-
-#ifndef IREE_INTEGRATIONS_TENSORFLOW_TFTENSORLIST_CONVERSION_CONVERTTFTENSORLISTTOTENSORLIST_H_
-#define IREE_INTEGRATIONS_TENSORFLOW_TFTENSORLIST_CONVERSION_CONVERTTFTENSORLISTTOTENSORLIST_H_
-
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.h"
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.h"
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/Pass/Pass.h"
-#include "mlir/Transforms/DialectConversion.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_tensorlist {
-
-std::unique_ptr<OperationPass<ModuleOp>>
-createConvertTFTensorListToTensorListPass();
-
-} // namespace tf_tensorlist
-} // namespace iree_integrations
-} // namespace mlir
-
-#endif
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.cc b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.cc
deleted file mode 100644
index 75ab31c..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.cc
+++ /dev/null
@@ -1,189 +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
-
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.h"
-#include "mlir/Dialect/StandardOps/IR/Ops.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/PatternMatch.h"
-#include "mlir/Pass/Pass.h"
-#include "mlir/Transforms/DialectConversion.h"
-#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"
-#include "tensorflow/compiler/mlir/tensorflow/ir/tf_types.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_tensorlist {
-
-namespace {
-TypeAttr GetVariantElementTypeAttr(Type type) {
- if (auto variantTy = type.dyn_cast<TF::VariantType>()) {
- return GetVariantElementTypeAttr(variantTy.getSubtypes().front());
- }
-
- if (auto shapedTy = type.dyn_cast<ShapedType>()) {
- return GetVariantElementTypeAttr(shapedTy.getElementType());
- }
-
- return TypeAttr::get(type);
-}
-
-} // namespace
-
-#include "iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.inc"
-
-class ConvertTFToTFTensorListPass
- : public PassWrapper<ConvertTFToTFTensorListPass, OperationPass<FuncOp>> {
- public:
- void getDependentDialects(DialectRegistry ®istry) const override {
- registry.insert<mlir::TF::TensorFlowDialect, TFTensorListDialect,
- StandardOpsDialect>();
- }
- void runOnOperation() override;
-};
-
-bool isTfVariant(Type type) {
- if (auto tensorType = type.dyn_cast<TensorType>()) {
- return tensorType.getElementType().isa<TF::VariantType>();
- }
- return false;
-}
-
-namespace {
-class ConvertTfTensorlistConcatV2
- : public OpRewritePattern<TF::TensorListConcatV2Op> {
- public:
- using OpRewritePattern<TF::TensorListConcatV2Op>::OpRewritePattern;
-
- LogicalResult matchAndRewrite(TF::TensorListConcatV2Op op,
- PatternRewriter &rewriter) const override {
- Value tensor_list = op.input_handle();
- Value out_tensor = op.tensor();
- Value out_lengths = op.lengths();
-
- Value concat = rewriter.create<tf_tensorlist::Concat>(
- op.getLoc(), out_tensor.getType(), tensor_list);
- Value dim0Lengths = rewriter.create<tf_tensorlist::GetDim0>(
- op.getLoc(), out_lengths.getType(), tensor_list);
-
- rewriter.replaceOp(op, {concat, dim0Lengths});
- return success();
- }
-};
-} // namespace
-
-void ConvertTFToTFTensorListPass::runOnOperation() {
- auto func = getOperation();
-
- // The conversion happens in 2 steps:
- // 1. We blindly replace all tf ops operating on TensorList's with
- // tf_tensorlist ops. No types change in this step (so the IR is transiently
- // invalid).
- // 2. We rewrite all the types to make the IR valid again.
- //
- // The reason we need to do the rewriting this way is that not all TF variant
- // types actually represent a tensorlist. Only by looking at ops that we know
- // produce tensorlists can we deduce which TF varaints are tensorlists.
- //
- // The MLIR type conversion infrastructure doesn't handle this situation well.
- // It only knows how to handle blindly convert one type to another type.
-
- OwningRewritePatternList patterns(&getContext());
- populateWithGenerated(patterns);
- patterns.insert<ConvertTfTensorlistConcatV2>(&getContext());
-
- ConversionTarget target(getContext());
- target.addLegalDialect<TFTensorListDialect>();
- target.addLegalDialect<TF::TensorFlowDialect>();
- target.addLegalDialect<StandardOpsDialect>();
- target.addIllegalOp<TF::TensorListReserveOp>();
- target.addIllegalOp<TF::TensorListGetItemOp>();
- target.addIllegalOp<TF::TensorListSetItemOp>();
- target.addIllegalOp<TF::TensorListFromTensorOp>();
- target.addIllegalOp<TF::TensorListConcatV2Op>();
- target.addIllegalOp<TF::TensorListStackOp>();
-
- if (failed(applyPartialConversion(func, target, std::move(patterns)))) {
- func.emitError() << "unable to lower to tf_tensorlist dialect";
- return signalPassFailure();
- }
-
- // The above conversions didn't do any type conversion since we don't
- // want to blindly update all variant types to tensorlist. So here we do a
- // targeted rewrite.
- auto *tfTensorListDialect =
- func.getContext()->getLoadedDialect<TFTensorListDialect>();
- auto tensorListType = TensorListType::get(func.getContext());
- SmallVector<Value, 8> typeConversionWorklist;
- func.walk([&](Operation *op) {
- if (op->getDialect() != tfTensorListDialect) {
- return;
- }
- for (auto result : op->getResults()) {
- if (isTfVariant(result.getType())) {
- result.setType(tensorListType);
- typeConversionWorklist.push_back(result);
- }
- }
- });
- while (!typeConversionWorklist.empty()) {
- Value v = typeConversionWorklist.pop_back_val();
- for (OpOperand &use : v.getUses()) {
- Operation *owner = use.getOwner();
- // If the user is already in the tf_tensorlist dialect then skip.
- if (owner->getDialect() == tfTensorListDialect) {
- continue;
- }
- // If a user is just a terminator passing the value through a successor
- // operand, propagate through the successor operand.
- if (BranchOpInterface branchOp = dyn_cast<BranchOpInterface>(owner)) {
- if (auto arg =
- branchOp.getSuccessorBlockArgument(use.getOperandNumber())) {
- if (!arg->getType().isa<TensorListType>()) {
- arg->setType(tensorListType);
- typeConversionWorklist.push_back(*arg);
- }
- continue;
- }
- }
- // !tf.variant can have various subtypes which we blindly turn into just
- // !tf_tensorlist.list here. So elide all casts.
- if (auto castOp = dyn_cast<TF::CastOp>(owner)) {
- assert(v == castOp.x());
- castOp.y().replaceAllUsesWith(castOp.x());
- castOp.erase();
- // The RAUW could have added more uses of `v`, so put it back on the
- // worklist and process it again.
- typeConversionWorklist.push_back(v);
- break;
- }
- // Depending on phase ordering, we may still have identity ops that
- // operate on these types. Just elide them if encountered.
- if (auto identityOp = dyn_cast<TF::IdentityOp>(owner)) {
- identityOp.output().replaceAllUsesWith(identityOp.input());
- identityOp.erase();
- // The RAUW could have added more uses of `v`, so put it back on the
- // worklist and process it again.
- typeConversionWorklist.push_back(v);
- break;
- }
- owner->emitError() << "unable to convert tensorlist op: "
- << owner->getName();
- return signalPassFailure();
- }
- }
-}
-
-static PassRegistration<ConvertTFToTFTensorListPass> pass(
- "iree-tf-convert-to-tf-tensorlist",
- "Converts TF tensor list ops to the IREE tf_tensorlist dialect");
-
-std::unique_ptr<OperationPass<FuncOp>> createConvertTFToTFTensorListPass() {
- return std::make_unique<ConvertTFToTFTensorListPass>();
-}
-
-} // namespace tf_tensorlist
-} // namespace iree_integrations
-} // namespace mlir
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.h
deleted file mode 100644
index 23a8486..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.h
+++ /dev/null
@@ -1,22 +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
-
-#ifndef IREE_INTEGRATIONS_TENSORFLOW_CONVERTTFTOTFTENSORLIST_H_
-#define IREE_INTEGRATIONS_TENSORFLOW_CONVERTTFTOTFTENSORLIST_H_
-
-#include "mlir/Pass/Pass.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_tensorlist {
-
-std::unique_ptr<OperationPass<FuncOp>> createConvertTFToTFTensorListPass();
-
-} // namespace tf_tensorlist
-} // namespace iree_integrations
-} // namespace mlir
-
-#endif // IREE_INTEGRATIONS_TENSORFLOW_CONVERTTFTOTFTENSORLIST_H_
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.td b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.td
deleted file mode 100644
index fc9216c..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.td
+++ /dev/null
@@ -1,34 +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
-
-include "mlir/IR/OpBase.td"
-include "mlir/Dialect/StandardOps/IR/Ops.td"
-include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.td"
-include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.td"
-
-// GetElementTypeAttr
-def GetVariantElementTypeAttr : NativeCodeCall<
- "GetVariantElementTypeAttr($0.getType())">;
-
-def : Pat<(TF_TensorListReserveOp:$result $element_shape, $num_elements),
- (TFTensorList_Reserve $element_shape, $num_elements,
- (GetVariantElementTypeAttr $result))>;
-
-def : Pat<(TF_TensorListGetItemOp $input_handle, $index, $element_shape),
- (TFTensorList_GetItem $input_handle, $index)>;
-
-def : Pat<(TF_TensorListSetItemOp $input_handle, $index, $item),
- (TFTensorList_SetItem $input_handle, $index, $item)>;
-
-def : Pat<(TF_TensorListFromTensorOp $tensor, $element_shape),
- (TFTensorList_FromTensor $tensor)>;
-
-def WrapScalarI64InTensor : NativeCodeCall<
- "DenseElementsAttr::get(RankedTensorType::get({}, $_builder.getIntegerType(64)), {$_self.getValue()})">;
-def : Pat<(TF_TensorListStackOp $input_handle, $element_shape, $num_elements),
- (TFTensorList_Stack
- $input_handle,
- (ConstantOp WrapScalarI64InTensor:$num_elements))>;
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/test/BUILD b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/test/BUILD
deleted file mode 100644
index 707ea8e..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/test/BUILD
+++ /dev/null
@@ -1,30 +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
-
-load("@iree//iree:lit_test.bzl", "iree_lit_test_suite")
-load("@iree//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(
- [
- "convert_tf_tensorlist_to_tensorlist.mlir",
- "convert_tf_to_tf_tensorlist.mlir",
- ],
- include = ["*.mlir"],
- ),
- data = [
- "//iree_tf_compiler:iree-tf-opt",
- "@iree//iree/tools:IreeFileCheck",
- ],
- driver = "@iree//iree/tools:run_lit.sh",
-)
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/test/convert_tf_tensorlist_to_tensorlist.mlir b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/test/convert_tf_tensorlist_to_tensorlist.mlir
deleted file mode 100644
index c36088e..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/test/convert_tf_tensorlist_to_tensorlist.mlir
+++ /dev/null
@@ -1,53 +0,0 @@
-// RUN: iree-tf-opt <%s -iree-tf-tensorlist-convert-to-tensorlist -split-input-file | IreeFileCheck %s
-
-// CHECK-LABEL: func @Reserve
-func @Reserve(%arg0: tensor<0xi32>, %arg1: tensor<i32>) -> !tf_tensorlist.list{
-// CHECK: "tensorlist.Reserve.Tensor"(%arg0, %arg1)
- %0 = "tf_tensorlist.Reserve"(%arg0, %arg1) {element_type = f32} : (tensor<0xi32>, tensor<i32>) -> !tf_tensorlist.list
- return %0 : !tf_tensorlist.list
-}
-
-// -----
-
-// CHECK-LABEL: func @FromTensorList
-func @FromTensorList(%arg0: tensor<10xi32>) -> !tf_tensorlist.list{
-// CHECK: "tensorlist.FromTensor"(%arg0)
- %0 = "tf_tensorlist.FromTensor"(%arg0) : (tensor<10xi32>) -> !tf_tensorlist.list
- return %0 : !tf_tensorlist.list
-}
-
-// -----
-
-// CHECK-LABEL: func @SetItem
-func @SetItem(%arg0: !tf_tensorlist.list, %arg1: tensor<i32>, %arg2: tensor<f32>) -> !tf_tensorlist.list{
-// CHECK: "tensorlist.SetItem"(%arg0, %arg1, %arg2)
- %0 = "tf_tensorlist.SetItem"(%arg0, %arg1, %arg2) : (!tf_tensorlist.list, tensor<i32>, tensor<f32>) -> !tf_tensorlist.list
- return %0 : !tf_tensorlist.list
-}
-
-// -----
-
-// CHECK-LABEL: func @GetItem
-func @GetItem(%arg0: !tf_tensorlist.list, %arg1: tensor<i32>) -> tensor<f32> {
-// CHECK: "tensorlist.GetItem"(%arg0, %arg1)
- %0 = "tf_tensorlist.GetItem"(%arg0, %arg1) : (!tf_tensorlist.list, tensor<i32>) -> tensor<f32>
- return %0 : tensor<f32>
-}
-
-// -----
-
-// CHECK-LABEL: func @Stack
-func @Stack(%arg0: !tf_tensorlist.list, %arg1: tensor<i32>) -> tensor<1xf32> {
-// CHECK: "tensorlist.Stack.Tensor"(%arg0, %arg1)
- %0 = "tf_tensorlist.Stack"(%arg0, %arg1) : (!tf_tensorlist.list, tensor<i32>) -> tensor<1xf32>
- return %0 : tensor<1xf32>
-}
-
-// -----
-
-// CHECK-LABEL: func @Concat
-func @Concat(%arg0: !tf_tensorlist.list) -> (tensor<1xf32>) {
-// CHECK: "tensorlist.Concat.Tensor"(%arg0)
- %0 = "tf_tensorlist.Concat"(%arg0) : (!tf_tensorlist.list) -> tensor<1xf32>
- return %0 : tensor<1xf32>
-}
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/test/convert_tf_to_tf_tensorlist.mlir b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/test/convert_tf_to_tf_tensorlist.mlir
deleted file mode 100644
index 4dafb17..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/conversion/test/convert_tf_to_tf_tensorlist.mlir
+++ /dev/null
@@ -1,126 +0,0 @@
-// RUN: iree-tf-opt %s -iree-tf-convert-to-tf-tensorlist -split-input-file -allow-unregistered-dialect -verify-diagnostics | IreeFileCheck %s
-
-// TODO(silvasean): Handle interprocedural conversion.
-
-// CHECK-LABEL: func @basic
-func @basic(%arg0: tensor<f32>, %num_elements: tensor<i32>, %element_shape: tensor<0xi32>, %index: tensor<i32>, %item: tensor<f32>) -> tensor<f32> {
- // CHECK-NEXT: [[LIST0:%.+]] = "tf_tensorlist.Reserve"(%arg2, %arg1) {element_type = f32} : (tensor<0xi32>, tensor<i32>) -> !tf_tensorlist.list
- // CHECK-NEXT: [[LIST1:%.+]] = "tf_tensorlist.SetItem"([[LIST0]], %arg3, %arg4) : (!tf_tensorlist.list, tensor<i32>, tensor<f32>) -> !tf_tensorlist.list
- // CHECK-NEXT: [[T:%.+]] = "tf_tensorlist.GetItem"([[LIST1]], %arg3) : (!tf_tensorlist.list, tensor<i32>) -> tensor<f32>
- // CHECK-NEXT: return [[T]] : tensor<f32>
- %list0 = "tf.TensorListReserve"(%element_shape, %num_elements) : (tensor<0xi32>, tensor<i32>) -> tensor<!tf.variant<tensor<f32>>>
- %list1 = "tf.TensorListSetItem"(%list0, %index, %item) : (tensor<!tf.variant<tensor<f32>>>, tensor<i32>, tensor<f32>) -> tensor<!tf.variant<tensor<f32>>>
- %t = "tf.TensorListGetItem"(%list1, %index, %element_shape) : (tensor<!tf.variant<tensor<f32>>>, tensor<i32>, tensor<0xi32>) -> tensor<f32>
- return %t : tensor<f32>
-}
-
-// CHECK-LABEL: func @stack
-func @stack(%arg0: tensor<?xf32>, %element_shape: tensor<0xi32>) -> tensor<?xf32> {
- // CHECK-NEXT: [[LIST0:%.+]] = "tf_tensorlist.FromTensor"(%arg0) : (tensor<?xf32>) -> !tf_tensorlist.list
- // CHECK-NEXT: [[CONST:%.+]] = constant dense<-1> : tensor<i64>
- // CHECK-NEXT: [[T:%.+]] = "tf_tensorlist.Stack"([[LIST0]], [[CONST]]) : (!tf_tensorlist.list, tensor<i64>) -> tensor<?xf32>
- // CHECK-NEXT: return [[T]]
-
- %list0 = "tf.TensorListFromTensor"(%arg0, %element_shape) : (tensor<?xf32>, tensor<0xi32>) -> tensor<!tf.variant<tensor<f32>>>
- %t = "tf.TensorListStack"(%list0, %element_shape) : (tensor<!tf.variant<tensor<f32>>>, tensor<0xi32>) -> tensor<?xf32>
- return %t : tensor<?xf32>
-}
-
-// CHECK-LABEL: func @concat
-func @concat(%arg0: tensor<?xf32>, %element_shape: tensor<0xi32>, %lead: tensor<i64>) -> (tensor<?xf32>, tensor<0xi64>) {
- // CHECK-DAG: [[LIST0:%.+]] = "tf_tensorlist.FromTensor"(%arg0)
- // CHECK-DAG: [[T:%.+]] = "tf_tensorlist.Concat"([[LIST0]])
- // CHECK-DAG: [[L:%.+]] = "tf_tensorlist.GetDim0"([[LIST0]])
- // CHECK: return [[T]], [[L]]
-
- %list0 = "tf.TensorListFromTensor"(%arg0, %element_shape) : (tensor<?xf32>, tensor<0xi32>) -> tensor<!tf.variant<tensor<f32>>>
- %t:2 = "tf.TensorListConcatV2"(%list0, %element_shape, %lead) : (tensor<!tf.variant<tensor<f32>>>, tensor<0xi32>, tensor<i64>) -> (tensor<?xf32>, tensor<0xi64>)
- return %t#0, %t#1 : tensor<?xf32>, tensor<0xi64>
-}
-
-// CHECK-LABEL: func @identity
-func @identity(%arg0: tensor<?xf32>, %element_shape: tensor<0xi32>, %lead: tensor<i64>) -> (tensor<?xf32>, tensor<0xi64>) {
- // CHECK-NOT: tf.Identity
- // CHECK: return
-
- %list0 = "tf.TensorListFromTensor"(%arg0, %element_shape) : (tensor<?xf32>, tensor<0xi32>) -> tensor<!tf.variant<tensor<f32>>>
- %ident = "tf.Identity"(%list0) : (tensor<!tf.variant<tensor<f32>>>) -> tensor<!tf.variant<tensor<f32>>>
- %t:2 = "tf.TensorListConcatV2"(%ident, %element_shape, %lead) : (tensor<!tf.variant<tensor<f32>>>, tensor<0xi32>, tensor<i64>) -> (tensor<?xf32>, tensor<0xi64>)
- return %t#0, %t#1 : tensor<?xf32>, tensor<0xi64>
-}
-
-// CHECK-LABEL: func @control_flow_simple
-func @control_flow_simple(%arg0: tensor<f32>, %num_elements: tensor<i32>, %element_shape: tensor<0xi32>, %index: tensor<i32>, %item: tensor<f32>) {
- // CHECK-NEXT: tf_tensorlist.Reserve
- // CHECK-NEXT: br ^bb1({{%.+}} : !tf_tensorlist.list)
- %list0 = "tf.TensorListReserve"(%element_shape, %num_elements) : (tensor<0xi32>, tensor<i32>) -> tensor<!tf.variant<tensor<f32>>>
- br ^bb1(%list0 : tensor<!tf.variant<tensor<f32>>>)
-^bb1(%list1: tensor<!tf.variant<tensor<f32>>>):
- // CHECK-NEXT: ^bb1({{%.+}}: !tf_tensorlist.list):
- // CHECK-NEXT: br ^bb2({{%.+}} : !tf_tensorlist.list)
- br ^bb2(%list1 : tensor<!tf.variant<tensor<f32>>>)
-^bb2(%list2: tensor<!tf.variant<tensor<f32>>>):
- // CHECK-NEXT: ^bb2({{%.+}}: !tf_tensorlist.list):
- // CHECK-NEXT: tf_tensorlist.SetItem
- %list3 = "tf.TensorListSetItem"(%list2, %index, %item) : (tensor<!tf.variant<tensor<f32>>>, tensor<i32>, tensor<f32>) -> tensor<!tf.variant<tensor<f32>>>
- return
-}
-
-// CHECK-LABEL: func @control_flow_converge
-func @control_flow_converge(%arg0: tensor<f32>, %pred: i1, %num_elements: tensor<i32>, %element_shape: tensor<0xi32>, %index: tensor<i32>, %item: tensor<f32>) {
- // CHECK-NEXT: tf_tensorlist.Reserve
- // CHECK-NEXT: cond_br %arg1, ^bb1({{%.+}} : !tf_tensorlist.list), ^bb1({{%.+}} : !tf_tensorlist.list)
- %list0 = "tf.TensorListReserve"(%element_shape, %num_elements) : (tensor<0xi32>, tensor<i32>) -> tensor<!tf.variant<tensor<f32>>>
- cond_br %pred, ^bb1(%list0 : tensor<!tf.variant<tensor<f32>>>), ^bb1(%list0 : tensor<!tf.variant<tensor<f32>>>)
-^bb1(%list_arg: tensor<!tf.variant<tensor<f32>>>):
- // CHECK-NEXT: ^bb1({{%.+}}: !tf_tensorlist.list):
- // CHECK-NEXT: tf_tensorlist.SetItem
- %list1 = "tf.TensorListSetItem"(%list_arg, %index, %item) : (tensor<!tf.variant<tensor<f32>>>, tensor<i32>, tensor<f32>) -> tensor<!tf.variant<tensor<f32>>>
- return
-}
-
-// CHECK-LABEL: func @control_flow_loop
-func @control_flow_loop(%arg0: tensor<f32>, %num_elements: tensor<i32>, %element_shape: tensor<0xi32>, %index: tensor<i32>, %item: tensor<f32>) {
- // CHECK-NEXT: tf_tensorlist.Reserve
- // CHECK-NEXT: br ^bb1({{%.+}} : !tf_tensorlist.list)
- %list0 = "tf.TensorListReserve"(%element_shape, %num_elements) : (tensor<0xi32>, tensor<i32>) -> tensor<!tf.variant<tensor<f32>>>
- br ^bb1(%list0 : tensor<!tf.variant<tensor<f32>>>)
-^bb1(%list_arg: tensor<!tf.variant<tensor<f32>>>):
- // CHECK-NEXT: ^bb1({{%.+}}: !tf_tensorlist.list):
- // CHECK-NEXT: tf_tensorlist.SetItem
- // CHECK-NEXT: br ^bb1({{%.+}} : !tf_tensorlist.list)
- %list1 = "tf.TensorListSetItem"(%list_arg, %index, %item) : (tensor<!tf.variant<tensor<f32>>>, tensor<i32>, tensor<f32>) -> tensor<!tf.variant<tensor<f32>>>
- br ^bb1(%list1 : tensor<!tf.variant<tensor<f32>>>)
-}
-
-// CHECK-LABEL: func @casting
-func @casting(%arg0: tensor<f32>, %num_elements: tensor<i32>, %element_shape: tensor<0xi32>, %index: tensor<i32>, %item: tensor<f32>) {
- // CHECK-NEXT: tf_tensorlist.Reserve
- // CHECK-NEXT: br ^bb1({{%.+}} : !tf_tensorlist.list)
- %list0 = "tf.TensorListReserve"(%element_shape, %num_elements) : (tensor<0xi32>, tensor<i32>) -> tensor<!tf.variant<tensor<f32>>>
- br ^bb1(%list0 : tensor<!tf.variant<tensor<f32>>>)
-^bb1(%list_arg: tensor<!tf.variant<tensor<f32>>>):
- // CHECK-NEXT: ^bb1({{%.+}}: !tf_tensorlist.list):
- // CHECK-NEXT: tf_tensorlist.SetItem
- // No cast.
- // CHECK-NEXT: br ^bb1({{%.+}} : !tf_tensorlist.list)
- %list1 = "tf.TensorListSetItem"(%list_arg, %index, %item) : (tensor<!tf.variant<tensor<f32>>>, tensor<i32>, tensor<f32>) -> tensor<!tf.variant>
- %list_casted = "tf.Cast"(%list1) {Truncate=false} : (tensor<!tf.variant>) -> tensor<!tf.variant<tensor<f32>>>
- br ^bb1(%list_casted : tensor<!tf.variant<tensor<f32>>>)
-}
-
-// CHECK-LABEL: func @non_tensorlist_variant
-func @non_tensorlist_variant() {
- // CHECK: "tf.ProducesSomeNonTensorListVariant"() : () -> tensor<!tf.variant>
- %0 = "tf.ProducesSomeNonTensorListVariant"() : () -> tensor<!tf.variant>
- // CHECK: "tf.ConsumesSomeNonTensorListVariant"(%0) : (tensor<!tf.variant>) -> ()
- "tf.ConsumesSomeNonTensorListVariant"(%0) : (tensor<!tf.variant>) -> ()
-}
-
-// -----
-
-func @unknown_op(%arg0: tensor<f32>, %num_elements: tensor<i32>, %element_shape: tensor<0xi32>) {
- %0 = "tf.TensorListReserve"(%element_shape, %num_elements) : (tensor<0xi32>, tensor<i32>) -> tensor<!tf.variant<tensor<f32>>>
- // expected-error@+1 {{unable to convert tensorlist op: unknown_dialect.unknown_op}}
- "unknown_dialect.unknown_op"(%0) : (tensor<!tf.variant<tensor<f32>>>) -> ()
-}
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/BUILD b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/BUILD
deleted file mode 100644
index ef4150a..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/BUILD
+++ /dev/null
@@ -1,87 +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
-
-load("@iree//build_tools/bazel:tblgen.bzl", "gentbl_cc_library")
-load("@iree//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-exports_files(["tf_tensorlist_base.td"])
-
-filegroup(
- name = "td_files",
- srcs = enforce_glob(
- [
- "tf_tensorlist_base.td",
- "tf_tensorlist_ops.td",
- ],
- include = ["*.td"],
- ),
-)
-
-cc_library(
- name = "ir",
- srcs = [
- "tf_tensorlist_ops.cc",
- "tf_tensorlist_types.cc",
- ],
- hdrs = [
- "tf_tensorlist_ops.h",
- "tf_tensorlist_ops.h.inc",
- "tf_tensorlist_types.h",
- ],
- textual_hdrs = [
- "tf_tensorlist_ops.cc.inc",
- ],
- deps = [
- ":tf_tensorlist_ops_gen",
- "@iree//iree/compiler/Dialect/HAL/IR",
- "@iree//iree/compiler/Dialect/IREE/IR",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:InferTypeOpInterface",
- "@llvm-project//mlir:SideEffects",
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow",
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow:tensorflow_types",
- ],
-)
-
-cc_library(
- name = "tf_tensorlist_dialect",
- srcs = ["tf_tensorlist_dialect.cc"],
- hdrs = ["tf_tensorlist_dialect.h"],
- deps = [
- ":ir",
- "@llvm-project//mlir:IR",
- ],
-)
-
-gentbl_cc_library(
- name = "tf_tensorlist_ops_gen",
- tbl_outs = [
- (
- ["-gen-op-decls"],
- "tf_tensorlist_ops.h.inc",
- ),
- (
- ["-gen-op-defs"],
- "tf_tensorlist_ops.cc.inc",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "tf_tensorlist_ops.td",
- td_includes = ["external/org_tensorflow"],
- td_srcs = [
- ":td_files",
- "@iree//iree/compiler/Dialect/IREE/IR:td_files",
- "@llvm-project//mlir:StdOpsTdFiles",
- "@llvm-project//mlir:include/mlir/Interfaces/InferTypeOpInterface.td",
- "@org_tensorflow//tensorflow/compiler/mlir/tensorflow:tensorflow_ops_td_files",
- ],
-)
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/test/BUILD b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/test/BUILD
deleted file mode 100644
index 1686e0e..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/test/BUILD
+++ /dev/null
@@ -1,27 +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
-
-load("@iree//iree:lit_test.bzl", "iree_lit_test_suite")
-load("@iree//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(
- ["ops.mlir"],
- include = ["*.mlir"],
- ),
- data = [
- "//iree_tf_compiler:iree-tf-opt",
- "@iree//iree/tools:IreeFileCheck",
- ],
- driver = "@iree//iree/tools:run_lit.sh",
-)
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/test/ops.mlir b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/test/ops.mlir
deleted file mode 100644
index 9e2c13d..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/test/ops.mlir
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: iree-tf-opt %s | iree-tf-opt | FileCheck %s --dump-input=fail
-
-// CHECK-LABEL: func @f
-func @f(
- %num_elements: tensor<i32>,
- %element_shape: tensor<1xi32>,
- %list: !tf_tensorlist.list,
- %index: tensor<i32>,
- %item: tensor<?xf32>
-) {
- // CHECK: tf_tensorlist.Reserve
- %2 = "tf_tensorlist.Reserve"(%element_shape, %num_elements) { element_type = f32 } : (tensor<1xi32>, tensor<i32>) -> !tf_tensorlist.list
- // CHECK: tf_tensorlist.GetItem
- %3 = "tf_tensorlist.GetItem"(%list, %index) : (!tf_tensorlist.list, tensor<i32>) -> tensor<?xf32>
- // CHECK: tf_tensorlist.SetItem
- %4 = "tf_tensorlist.SetItem"(%list, %index, %item) : (!tf_tensorlist.list, tensor<i32>, tensor<?xf32>) -> !tf_tensorlist.list
- // CHECK: tf_tensorlist.Stack
- %5 = "tf_tensorlist.Stack"(%list, %index) : (!tf_tensorlist.list, tensor<i32>) -> tensor<1x2xf32>
- // CHECK: tf_tensorlist.Concat
- %6 = "tf_tensorlist.Concat"(%list) : (!tf_tensorlist.list) -> tensor<1x2xf32>
- // CHECK: tf_tensorlist.GetDim0
- %7 = "tf_tensorlist.GetDim0"(%list) : (!tf_tensorlist.list) -> tensor<1x2xf32>
- return
-}
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_base.td b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_base.td
deleted file mode 100644
index 96eb356..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_base.td
+++ /dev/null
@@ -1,32 +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
-
-#ifndef IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_DIALECT_TF_TENSORLIST_IR_TF_TENSORLIST_BASE_TD
-#define IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_DIALECT_TF_TENSORLIST_IR_TF_TENSORLIST_BASE_TD
-
-include "iree/compiler/Dialect/IREE/IR/IREEBase.td"
-
-def TFTensorList_Dialect : Dialect {
- let name = "tf_tensorlist";
-
- let summary = "Dialect used to represent TensorFlow TensorList's in MLIR.";
-
- let description = [{
- This is a "frontend" dialect intended to map 1:1 to TensorFlow's TensorList
- ops. The main difference from the `tf` dialect is that this dialect
- has a dedicated TensorList type, instead of using a `tensor<!tf.variant>`
- to represent TensorLists.
-
- This allows representing the TensorList construct with greater fidelity.
- }];
-
- let cppNamespace = "::mlir::iree_integrations::tf_tensorlist";
-}
-
-def TFTensorList_TensorList :
- Type<CPred<"$_self.isa<mlir::iree_integrations::tf_tensorlist::TensorListType>()">, "list">;
-
-#endif // IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_DIALECT_TF_TENSORLIST_IR_TF_TENSORLIST_BASE_TD
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.cc b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.cc
deleted file mode 100644
index 75b3560..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.cc
+++ /dev/null
@@ -1,47 +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
-
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.h"
-
-#include "mlir/IR/DialectImplementation.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_tensorlist {
-
-//===----------------------------------------------------------------------===//
-// TFTensorListDialect Dialect
-//===----------------------------------------------------------------------===//
-
-TFTensorListDialect::TFTensorListDialect(MLIRContext *context)
- : Dialect(getDialectNamespace(), context,
- TypeID::get<TFTensorListDialect>()) {
- addOperations<
-#define GET_OP_LIST
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.cc.inc"
- >();
- addTypes<TensorListType>();
-}
-
-Type TFTensorListDialect::parseType(DialectAsmParser &parser) const {
- StringRef type_name;
- if (parser.parseKeyword(&type_name)) return nullptr;
- if (type_name == "list") {
- return TensorListType::get(getContext());
- }
- parser.emitError(parser.getCurrentLocation(),
- "unknown type in `tf_tensorlist` dialect");
- return nullptr;
-}
-
-void TFTensorListDialect::printType(Type type,
- DialectAsmPrinter &printer) const {
- printer << "list";
-}
-
-} // namespace tf_tensorlist
-} // namespace iree_integrations
-} // namespace mlir
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.h
deleted file mode 100644
index e01c877..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.h
+++ /dev/null
@@ -1,30 +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
-
-#ifndef TENSORFLOW_COMPILER_MLIR_TENSORFLOW_IR_tf_tensorlist_H_
-#define TENSORFLOW_COMPILER_MLIR_TENSORFLOW_IR_tf_tensorlist_H_
-
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.h"
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.h"
-#include "mlir/IR/Dialect.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_tensorlist {
-
-class TFTensorListDialect : public Dialect {
- public:
- static StringRef getDialectNamespace() { return "tf_tensorlist"; }
- explicit TFTensorListDialect(MLIRContext *context);
- Type parseType(DialectAsmParser &parser) const override;
- void printType(Type type, DialectAsmPrinter &printer) const override;
-};
-
-} // namespace tf_tensorlist
-} // namespace iree_integrations
-} // namespace mlir
-
-#endif // TENSORFLOW_COMPILER_MLIR_TENSORFLOW_IR_tf_tensorlist_H_
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.cc b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.cc
deleted file mode 100644
index 64a8af7..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.cc
+++ /dev/null
@@ -1,12 +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
-
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.h"
-
-#include "mlir/IR/Builders.h"
-
-#define GET_OP_CLASSES
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.cc.inc"
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.h
deleted file mode 100644
index 6c703b4..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.h
+++ /dev/null
@@ -1,20 +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
-
-#ifndef IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_TF_TENSORLIST_OPS_H_
-#define IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_TF_TENSORLIST_OPS_H_
-
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.h"
-#include "mlir/IR/OpDefinition.h"
-#include "mlir/Interfaces/InferTypeOpInterface.h"
-#include "mlir/Interfaces/SideEffectInterfaces.h"
-#include "tensorflow/compiler/mlir/tensorflow/ir/tf_types.h"
-
-// Declares the operations for this dialect using the generated header.
-#define GET_OP_CLASSES
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.h.inc"
-
-#endif // IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_TF_TENSORLIST_OPS_H_
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.td b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.td
deleted file mode 100644
index 6a0a23f..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_ops.td
+++ /dev/null
@@ -1,171 +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
-
-#ifndef IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_DIALECT_TF_TENSORLIST_IR_TF_TENSORLIST_OPS_TD
-#define IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_DIALECT_TF_TENSORLIST_IR_TF_TENSORLIST_OPS_TD
-
-include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_base.td"
-include "mlir/IR/OpBase.td"
-include "mlir/Interfaces/InferTypeOpInterface.td"
-include "tensorflow/compiler/mlir/tensorflow/ir/tf_op_base.td"
-
-class TFTensorList_Op<string mnemonic, list<OpTrait> traits = []> :
- Op<TFTensorList_Dialect, mnemonic, traits> {
-}
-
-def TFTensorList_Reserve : TFTensorList_Op<"Reserve"> {
- let summary = "Return a TensorList of the given size with empty elements.";
-
- let description = [{
- Returns a TensorList with capacity for `num_elements` of presumed partial
- shape `element_shape`.
- }];
-
- let arguments = (ins
- TF_I32OrI64Tensor:$element_shape,
- I32Tensor:$num_elements,
- TypeAttr:$element_type
- );
-
- let results = (outs
- TFTensorList_TensorList:$list
- );
-}
-
-def TFTensorList_GetItem : TFTensorList_Op<"GetItem"> {
- let summary = "Returns an item of the TensorList.";
-
- let description = [{
- Returns the item at index `index` from the TensorList.
-
- If index is out of bounds of the valid tensors, but is in bounds of the
- reserved capacity, then `element_shape` controls the shape of the returned
- value, which will be filled with zeros.
-
- If element_shape is a fully defined shape (that is, contains no `-1` values),
- then zeros of that shape are returned. Otherwise, that shape is merged with
- the shape of all the other valid tensors in the list (that is an O(N)
- operation), and the resulting shape is used for creating the zeros.
-
- See the TensorFlow [implementation](https://github.com/tensorflow/tensorflow/blob/2e6a3c58e4b96cac864f244e4886ef00b3184986/tensorflow/core/kernels/list_kernels.h#L168).
- }];
-
- let arguments = (ins
- TFTensorList_TensorList:$list,
- I32Tensor:$index
- );
-
- let results = (outs
- TF_Tensor:$item
- );
-}
-
-def TFTensorList_SetItem : TFTensorList_Op<"SetItem"> {
- let summary = "Sets an item of the TensorList, returning an updated list.";
-
- let description = [{
- Returns a new TensorList which is the same as `list` but with the item at
- index `index` replaced with `item`.
- }];
-
- let arguments = (ins
- TFTensorList_TensorList:$list,
- I32Tensor:$index,
- TF_Tensor:$item
- );
-
- let results = (outs
- TFTensorList_TensorList:$new_list
- );
-}
-
-def TFTensorList_FromTensor : TFTensorList_Op<"FromTensor", [NoSideEffect]> {
- let summary = [{
- Creates a TensorList which, when stacked, has the value of `tensor`.
- }];
-
- let description = [{
- Each tensor in the result list corresponds to one row of the input tensor.
-
- tensor: The input tensor.
- list: The list.
- }];
-
- let arguments = (ins
- TF_Tensor:$tensor
- );
-
- let results = (outs
- TFTensorList_TensorList:$list
- );
-}
-
-def TFTensorList_Stack : TFTensorList_Op<"Stack", [NoSideEffect]> {
- let summary = "Stacks all tensors in the list.";
-
- let description = [{
- Requires that all tensors have the same shape.
-
- list: the input list
- tensor: the gathered result
- num_elements: optional. If not -1, the number of elements in the list.
- }];
-
- let arguments = (ins
- TFTensorList_TensorList:$list,
- // TODO(silvasean): Properly handle IREE's blind truncation to 32-bit.
- // This is logically `index` type, but coming from TensorFlow it
- // comes in as i64. IREE then proceeds to blindly truncate it to I32
- // in-place. So relax this from I64Tensor to I32Or64Tensor.
- TF_I32OrI64Tensor:$num_elements
- );
-
- let results = (outs
- TF_Tensor:$tensor
- );
-}
-
-def TFTensorList_Concat : TFTensorList_Op<"Concat", [NoSideEffect]> {
- let summary = "Concatenates all tensors in the list along the first dimension.";
-
- let description = [{
- Requires that all tensors have the same shape along dimensions 1+.
-
- list: the input list
- tensor: the concatenated result
- }];
-
- let arguments = (ins
- TFTensorList_TensorList:$list
- );
-
- let results = (outs
- TF_Tensor:$tensor
- );
-}
-
-// TODO(suderman): If gradients are not being calculated, the value will be
-// DCE'd.
-def TFTensorList_GetDim0 : TFTensorList_Op<"GetDim0", [NoSideEffect]> {
- let summary = "Returns a tensor of the lengths of Dim0 for the tensorlists' tensors";
-
- let description = [{
- Requires that all tensors have 1+ dimensions.
-
- list: the input list
- tensor: a 1-D tensor of length size of Dim-1 for each tensor.
- }];
-
- let arguments = (ins
- TFTensorList_TensorList:$list
- );
-
- let results = (outs
- TF_Tensor:$tensor
- );
-}
-
-#endif // IREE_INTEGRATIONS_TENSORFLOW_IREE_TF_COMPILER_DIALECT_TF_TENSORLIST_IR_TF_TENSORLIST_OPS_TD
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.cc b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.cc
deleted file mode 100644
index b2124ac..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.cc
+++ /dev/null
@@ -1,7 +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
-
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.h"
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.h b/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.h
deleted file mode 100644
index 49ce1b9..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_types.h
+++ /dev/null
@@ -1,26 +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
-
-#ifndef THIRD_PARTY_TENSORFLOW_COMPILER_MLIR_TENSORFLOW_IR_TF_TENSORLIST_TYPES_H_
-#define THIRD_PARTY_TENSORFLOW_COMPILER_MLIR_TENSORFLOW_IR_TF_TENSORLIST_TYPES_H_
-
-#include "iree/compiler/Dialect/IREE/IR/IREETypes.h"
-
-namespace mlir {
-namespace iree_integrations {
-namespace tf_tensorlist {
-
-class TensorListType
- : public Type::TypeBase<TensorListType, Type, TypeStorage> {
- public:
- using Base::Base;
-};
-
-} // namespace tf_tensorlist
-} // namespace iree_integrations
-} // namespace mlir
-
-#endif // THIRD_PARTY_TENSORFLOW_COMPILER_MLIR_TENSORFLOW_IR_TF_TENSORLIST_TYPES_H_
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/utils/BUILD b/integrations/tensorflow/iree_tf_compiler/dialect/utils/BUILD
deleted file mode 100644
index 9ffe556..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/utils/BUILD
+++ /dev/null
@@ -1,26 +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
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-cc_library(
- name = "conversion_utils",
- hdrs = [
- "conversion_utils.h",
- ],
- deps = [
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:StandardOps",
- "@llvm-project//mlir:StandardOpsTransforms",
- "@llvm-project//mlir:Support",
- "@llvm-project//mlir:Transforms",
- ],
-)
diff --git a/integrations/tensorflow/iree_tf_compiler/dialect/utils/conversion_utils.h b/integrations/tensorflow/iree_tf_compiler/dialect/utils/conversion_utils.h
deleted file mode 100644
index c56df8f..0000000
--- a/integrations/tensorflow/iree_tf_compiler/dialect/utils/conversion_utils.h
+++ /dev/null
@@ -1,100 +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
-
-#include "mlir/Dialect/StandardOps/IR/Ops.h"
-#include "mlir/Dialect/StandardOps/Transforms/FuncConversions.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/PatternMatch.h"
-#include "mlir/Pass/Pass.h"
-#include "mlir/Pass/PassRegistry.h"
-#include "mlir/Support/LogicalResult.h"
-#include "mlir/Transforms/DialectConversion.h"
-
-namespace mlir {
-namespace iree_integrations {
-
-template <typename SRC, typename DST>
-class OpConversion : public OpConversionPattern<SRC> {
- public:
- OpConversion(MLIRContext *context) : OpConversionPattern<SRC>(context) {}
-
- LogicalResult matchAndRewrite(
- SRC srcOp, ArrayRef<Value> operands,
- ConversionPatternRewriter &rewriter) const override {
- auto operation = srcOp.getOperation();
- rewriter.replaceOpWithNewOp<DST>(srcOp, operation->getResultTypes(),
- operands, operation->getAttrs());
- return success();
- }
-};
-
-template <typename T, typename Converter>
-class ConversionPass : public PassWrapper<T, OperationPass<ModuleOp>> {
- public:
- virtual void Setup(ConversionTarget &target,
- OwningRewritePatternList &pattern) = 0;
-
- void runOnOperation() override {
- if (failed(run())) {
- this->signalPassFailure();
- }
- }
-
- LogicalResult run() {
- auto module = this->getOperation();
- OwningRewritePatternList patterns(&this->getContext());
- Converter typeConverter;
-
- // Lower to the standard string operations.
- ConversionTarget target(this->getContext());
- Setup(target, patterns);
-
- // Add Dynamic legal ops for calls, returns, and functions.
- target.addDynamicallyLegalOp<FuncOp>([](FuncOp op) {
- Converter typeConverter;
- return typeConverter.isSignatureLegal(op.getType()) &&
- typeConverter.isLegal(&op.getBody());
- });
-
- target.addDynamicallyLegalOp<ReturnOp>([](ReturnOp op) {
- Converter typeConverter;
- auto func = [&](Type type) { return typeConverter.isLegal(type); };
- return llvm::all_of(op.getOperandTypes(), func);
- });
-
- target.addDynamicallyLegalOp<CallOp>([](CallOp op) {
- Converter typeConverter;
- auto func = [&](Type type) { return typeConverter.isLegal(type); };
- return llvm::all_of(op.getOperandTypes(), func) &&
- llvm::all_of(op.getResultTypes(), func);
- });
-
- populateFuncOpTypeConversionPattern(patterns, typeConverter);
- populateCallOpTypeConversionPattern(patterns, typeConverter);
-
- auto result = applyPartialConversion(module.getOperation(), target,
- std::move(patterns));
-
- // Partial conversion doesn't include return types. Update in a separate
- // walk.
- module.walk([&](Operation *op) {
- for (auto result : op->getResults()) {
- auto result_type = result.getType();
- auto new_type = typeConverter.convertType(result_type);
- if (new_type) {
- result.setType(typeConverter.convertType(result_type));
- }
- }
- });
-
- return result;
- }
-};
-
-} // namespace iree_integrations
-} // namespace mlir
diff --git a/integrations/tensorflow/iree_tf_compiler/iree-tf-opt-main.cpp b/integrations/tensorflow/iree_tf_compiler/iree-tf-opt-main.cpp
index 220bbb7..014a2ca 100644
--- a/integrations/tensorflow/iree_tf_compiler/iree-tf-opt-main.cpp
+++ b/integrations/tensorflow/iree_tf_compiler/iree-tf-opt-main.cpp
@@ -13,13 +13,9 @@
#include "iree/compiler/Dialect/Flow/IR/FlowDialect.h"
#include "iree/compiler/Dialect/HAL/IR/HALDialect.h"
#include "iree/compiler/Dialect/IREE/IR/IREEDialect.h"
-#include "iree/compiler/Dialect/Modules/Strings/IR/Dialect.h"
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.h"
#include "iree/tools/init_xla_dialects.h"
#include "iree_tf_compiler/MHLO/Passes.h"
#include "iree_tf_compiler/TF/Passes.h"
-#include "iree_tf_compiler/dialect/tf_strings/ir/dialect.h"
-#include "iree_tf_compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.h"
#include "llvm/Support/InitLLVM.h"
#include "mlir/Dialect/Shape/Transforms/Passes.h"
#include "mlir/IR/Dialect.h"
@@ -35,15 +31,9 @@
mlir::registerXLADialects(registry);
registry.insert<mlir::iree_compiler::IREE::Flow::FlowDialect,
mlir::iree_compiler::IREE::HAL::HALDialect,
- mlir::iree_compiler::IREEDialect,
- mlir::iree_compiler::IREE::Strings::StringsDialect,
- mlir::iree_compiler::IREE::TensorList::TensorListDialect>();
- registry.insert<mlir::iree_integrations::tf_strings::TFStringsDialect>();
- registry
- .insert<mlir::iree_integrations::tf_tensorlist::TFTensorListDialect>();
+ mlir::iree_compiler::IREEDialect>();
mlir::RegisterAllTensorFlowDialects(registry);
- mlir::iree_integrations::TF::registerAllDialects(registry);
mlir::iree_integrations::TF::registerAllPasses();
mlir::iree_integrations::MHLO::registerAllPasses();
diff --git a/iree/compiler/Dialect/Modules/Strings/BUILD b/iree/compiler/Dialect/Modules/Strings/BUILD
deleted file mode 100644
index 3058cbc..0000000
--- a/iree/compiler/Dialect/Modules/Strings/BUILD
+++ /dev/null
@@ -1,22 +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")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-c_embed_data(
- name = "strings_imports",
- srcs = ["strings.imports.mlir"],
- c_file_output = "strings.imports.c",
- flatten = True,
- h_file_output = "strings.imports.h",
- identifier = "iree_strings_imports",
-)
diff --git a/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt
deleted file mode 100644
index b5e78fe..0000000
--- a/iree/compiler/Dialect/Modules/Strings/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/Strings/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_c_embed_data(
- NAME
- strings_imports
- SRCS
- "strings.imports.mlir"
- C_FILE_OUTPUT
- "strings.imports.c"
- H_FILE_OUTPUT
- "strings.imports.h"
- IDENTIFIER
- "iree_strings_imports"
- FLATTEN
- PUBLIC
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/Strings/Conversion/BUILD b/iree/compiler/Dialect/Modules/Strings/Conversion/BUILD
deleted file mode 100644
index 6f53085..0000000
--- a/iree/compiler/Dialect/Modules/Strings/Conversion/BUILD
+++ /dev/null
@@ -1,33 +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
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-cc_library(
- name = "Conversion",
- srcs = [
- "ConversionPatterns.cc",
- ],
- hdrs = [
- "ConversionPatterns.h",
- ],
- deps = [
- "//iree/compiler/Dialect/HAL/Conversion",
- "//iree/compiler/Dialect/IREE/IR",
- "//iree/compiler/Dialect/Modules/Strings/IR",
- "//iree/compiler/Dialect/VM/Conversion",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Parser",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:Support",
- "@llvm-project//mlir:Transforms",
- ],
-)
diff --git a/iree/compiler/Dialect/Modules/Strings/Conversion/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/Conversion/CMakeLists.txt
deleted file mode 100644
index ea92f11..0000000
--- a/iree/compiler/Dialect/Modules/Strings/Conversion/CMakeLists.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/Strings/Conversion/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
- Conversion
- HDRS
- "ConversionPatterns.h"
- SRCS
- "ConversionPatterns.cc"
- DEPS
- LLVMSupport
- MLIRIR
- MLIRParser
- MLIRPass
- MLIRSupport
- MLIRTransforms
- iree::compiler::Dialect::HAL::Conversion
- iree::compiler::Dialect::IREE::IR
- iree::compiler::Dialect::Modules::Strings::IR
- iree::compiler::Dialect::VM::Conversion
- PUBLIC
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/Strings/Conversion/ConversionPatterns.cc b/iree/compiler/Dialect/Modules/Strings/Conversion/ConversionPatterns.cc
deleted file mode 100644
index b0904fd..0000000
--- a/iree/compiler/Dialect/Modules/Strings/Conversion/ConversionPatterns.cc
+++ /dev/null
@@ -1,50 +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
-
-#include "iree/compiler/Dialect/Modules/Strings/Conversion/ConversionPatterns.h"
-
-#include "iree/compiler/Dialect/HAL/Conversion/ConversionTarget.h"
-#include "iree/compiler/Dialect/Modules/Strings/IR/Ops.h"
-#include "iree/compiler/Dialect/VM/Conversion/ImportUtils.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace Strings {
-
-void populateStringsToHALPatterns(MLIRContext *context,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter) {
- patterns.insert<HALOpConversion<IREE::Strings::ToStringTensorOp,
- IREE::Strings::ToStringTensorOp>>(
- context, typeConverter);
- patterns.insert<
- HALOpConversion<IREE::Strings::GatherOp, IREE::Strings::GatherOp>>(
- context, typeConverter);
-}
-
-void populateStringsToVMPatterns(MLIRContext *context,
- SymbolTable &importSymbols,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter) {
- patterns.insert<VMImportOpConversion<IREE::Strings::I32ToStringOp>>(
- context, importSymbols, typeConverter, "strings.i32_to_string");
- patterns.insert<VMImportOpConversion<IREE::Strings::PrintOp>>(
- context, importSymbols, typeConverter, "strings.print");
- patterns.insert<VMImportOpConversion<IREE::Strings::ToStringTensorOp>>(
- context, importSymbols, typeConverter, "strings.to_string_tensor");
- patterns.insert<VMImportOpConversion<IREE::Strings::StringTensorToStringOp>>(
- context, importSymbols, typeConverter, "strings.string_tensor_to_string");
- patterns.insert<VMImportOpConversion<IREE::Strings::GatherOp>>(
- context, importSymbols, typeConverter, "strings.gather");
- patterns.insert<VMImportOpConversion<IREE::Strings::ConcatOp>>(
- context, importSymbols, typeConverter, "strings.concat");
-}
-
-} // namespace Strings
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
diff --git a/iree/compiler/Dialect/Modules/Strings/Conversion/ConversionPatterns.h b/iree/compiler/Dialect/Modules/Strings/Conversion/ConversionPatterns.h
deleted file mode 100644
index e37a5a7..0000000
--- a/iree/compiler/Dialect/Modules/Strings/Conversion/ConversionPatterns.h
+++ /dev/null
@@ -1,34 +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
-
-#ifndef IREE_COMPILER_DIALECT_MODULES_STRINGS_CONVERSION_CONVERSION_PATTERNS_H_
-#define IREE_COMPILER_DIALECT_MODULES_STRINGS_CONVERSION_CONVERSION_PATTERNS_H_
-
-#include "mlir/Pass/Pass.h"
-#include "mlir/Transforms/DialectConversion.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace Strings {
-
-// Populates conversion patterns from the string dialect to the VM dialect.
-void populateStringsToHALPatterns(MLIRContext *context,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter);
-
-// Populates conversion patterns from the string dialect to the VM dialect.
-void populateStringsToVMPatterns(MLIRContext *context,
- SymbolTable &importSymbols,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter);
-
-} // namespace Strings
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_DIALECT_MODULES_STRINGS_CONVERSION_CONVERSION_PATTERNS_H_
diff --git a/iree/compiler/Dialect/Modules/Strings/Conversion/test/BUILD b/iree/compiler/Dialect/Modules/Strings/Conversion/test/BUILD
deleted file mode 100644
index b785aac..0000000
--- a/iree/compiler/Dialect/Modules/Strings/Conversion/test/BUILD
+++ /dev/null
@@ -1,26 +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
-
-load("//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(
- ["convert_to_hal.mlir"],
- include = ["*.mlir"],
- ),
- data = [
- "//iree/tools:IreeFileCheck",
- "//iree/tools:iree-opt",
- ],
-)
diff --git a/iree/compiler/Dialect/Modules/Strings/Conversion/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/Conversion/test/CMakeLists.txt
deleted file mode 100644
index 1d7774a..0000000
--- a/iree/compiler/Dialect/Modules/Strings/Conversion/test/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/Strings/Conversion/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
- "convert_to_hal.mlir"
- DATA
- iree::tools::IreeFileCheck
- iree::tools::iree-opt
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/Strings/Conversion/test/convert_to_hal.mlir b/iree/compiler/Dialect/Modules/Strings/Conversion/test/convert_to_hal.mlir
deleted file mode 100644
index 40337b7..0000000
--- a/iree/compiler/Dialect/Modules/Strings/Conversion/test/convert_to_hal.mlir
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: iree-opt --iree-convert-to-hal %s --split-input-file | IreeFileCheck %s
-
-// CHECK: func @to_string_tensor.f32(%arg0: !hal.buffer)
-func @to_string_tensor.f32(%arg0: tensor<5xf32>) -> !strings.string_tensor {
- // CHECK: [[VIEW:%.+]] = hal.buffer_view.create %arg0
- // CHECK: [[V0:%.+]] = "strings.to_string_tensor"([[VIEW]])
- %0 = "strings.to_string_tensor"(%arg0) : (tensor<5xf32>) -> !strings.string_tensor
-
- // CHECK: return [[V0]]
- return %0 : !strings.string_tensor
-}
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/BUILD b/iree/compiler/Dialect/Modules/Strings/IR/BUILD
deleted file mode 100644
index 4068c58..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/BUILD
+++ /dev/null
@@ -1,114 +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_tablegen_doc.bzl", "iree_tablegen_doc")
-load("//build_tools/bazel:tblgen.bzl", "gentbl_cc_library")
-load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-filegroup(
- name = "td_files",
- srcs = enforce_glob(
- ["Ops.td"],
- include = ["*.td"],
- ),
-)
-
-cc_library(
- name = "IR",
- srcs = [
- "Ops.cc",
- "Ops.cc.inc",
- ],
- hdrs = [
- "Ops.h",
- "Ops.h.inc",
- "Types.h",
- ],
- deps = [
- ":Ops_gen",
- "//iree/compiler/Dialect/HAL/IR",
- "//iree/compiler/Dialect/IREE/IR",
- "//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:Support",
- "@llvm-project//mlir:Transforms",
- ],
-)
-
-cc_library(
- name = "Dialect",
- srcs = [
- "Dialect.cc",
- ],
- hdrs = [
- "Dialect.h",
- ],
- deps = [
- ":IR",
- ":Ops_gen",
- "//iree/compiler/Dialect/HAL/Conversion",
- "//iree/compiler/Dialect/IREE/IR",
- "//iree/compiler/Dialect/Modules/Strings:strings_imports",
- "//iree/compiler/Dialect/Modules/Strings/Conversion",
- "//iree/compiler/Dialect/VM/Conversion",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Parser",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:Support",
- "@llvm-project//mlir:Transforms",
- ],
-)
-
-gentbl_cc_library(
- name = "Ops_gen",
- tbl_outs = [
- (
- ["-gen-op-decls"],
- "Ops.h.inc",
- ),
- (
- ["-gen-op-defs"],
- "Ops.cc.inc",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "Ops.td",
- td_srcs = [
- ":td_files",
- "//iree/compiler/Dialect/HAL/IR:td_files",
- "//iree/compiler/Dialect/IREE/IR:td_files",
- "@llvm-project//mlir:StdOpsTdFiles",
- ],
-)
-
-iree_tablegen_doc(
- name = "DialectDocGen",
- tbl_outs = [
- (
- ["-gen-dialect-doc"],
- "StringsDialect.md",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "Ops.td",
- td_srcs = [
- ":td_files",
- "//iree/compiler/Dialect/HAL/IR:td_files",
- "//iree/compiler/Dialect/IREE/IR:td_files",
- "@llvm-project//mlir:StdOpsTdFiles",
- ],
-)
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt
deleted file mode 100644
index 636318f..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/CMakeLists.txt
+++ /dev/null
@@ -1,79 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/Strings/IR/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
- IR
- HDRS
- "Ops.h"
- "Ops.h.inc"
- "Types.h"
- SRCS
- "Ops.cc"
- "Ops.cc.inc"
- DEPS
- LLVMSupport
- MLIRIR
- MLIRParser
- MLIRPass
- MLIRSideEffectInterfaces
- MLIRSupport
- MLIRTransforms
- iree::compiler::Dialect::HAL::IR
- iree::compiler::Dialect::IREE::IR
- iree::compiler::Dialect::VM::Conversion
- PUBLIC
-)
-
-iree_cc_library(
- NAME
- Dialect
- HDRS
- "Dialect.h"
- SRCS
- "Dialect.cc"
- DEPS
- ::IR
- LLVMSupport
- MLIRIR
- MLIRParser
- MLIRPass
- MLIRSupport
- MLIRTransforms
- iree::compiler::Dialect::HAL::Conversion
- iree::compiler::Dialect::IREE::IR
- iree::compiler::Dialect::Modules::Strings::Conversion
- iree::compiler::Dialect::Modules::Strings::strings_imports
- iree::compiler::Dialect::VM::Conversion
- PUBLIC
-)
-
-iree_tablegen_library(
- NAME
- Ops_gen
- TD_FILE
- "Ops.td"
- OUTS
- -gen-op-decls Ops.h.inc
- -gen-op-defs Ops.cc.inc
-)
-
-iree_tablegen_doc(
- NAME
- DialectDocGen
- TD_FILE
- "Ops.td"
- OUTS
- -gen-dialect-doc StringsDialect.md
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc b/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc
deleted file mode 100644
index 8fe8134..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc
+++ /dev/null
@@ -1,127 +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
-
-#include "iree/compiler/Dialect/Modules/Strings/IR/Dialect.h"
-
-#include "iree/compiler/Dialect/HAL/Conversion/ConversionDialectInterface.h"
-#include "iree/compiler/Dialect/HAL/Conversion/ConversionTarget.h"
-#include "iree/compiler/Dialect/Modules/Strings/Conversion/ConversionPatterns.h"
-#include "iree/compiler/Dialect/Modules/Strings/IR/Ops.h"
-#include "iree/compiler/Dialect/Modules/Strings/strings.imports.h"
-#include "iree/compiler/Dialect/VM/Conversion/ConversionDialectInterface.h"
-#include "llvm/ADT/StringSwitch.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/DialectImplementation.h"
-#include "mlir/IR/SymbolTable.h"
-#include "mlir/Parser.h"
-#include "mlir/Transforms/DialectConversion.h"
-#include "mlir/Transforms/InliningUtils.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace Strings {
-
-namespace {
-
-struct StringsInlinerInterface : public DialectInlinerInterface {
- using DialectInlinerInterface::DialectInlinerInterface;
-
- bool isLegalToInline(Operation *call, Operation *callable,
- bool wouldBeCloned) const final {
- // Sure!
- return true;
- }
-
- bool isLegalToInline(Region *dest, Region *src, bool wouldBeCloned,
- BlockAndValueMapping &valueMapping) const final {
- // Sure!
- return true;
- }
-
- bool isLegalToInline(Operation *op, Region *dest, bool wouldBeCloned,
- BlockAndValueMapping &valueMapping) const final {
- // Sure!
- return true;
- }
-};
-
-class StringsToVMConversionInterface : public VMConversionDialectInterface {
- public:
- using VMConversionDialectInterface::VMConversionDialectInterface;
-
- OwningModuleRef parseVMImportModule() const override {
- return mlir::parseSourceString(
- StringRef(iree_strings_imports_create()->data,
- iree_strings_imports_create()->size),
- getDialect()->getContext());
- }
-
- void populateVMConversionPatterns(
- SymbolTable &importSymbols, OwningRewritePatternList &patterns,
- TypeConverter &typeConverter) const override {
- populateStringsToVMPatterns(getDialect()->getContext(), importSymbols,
- patterns, typeConverter);
- }
-};
-
-class StringsToHALConversionInterface : public HALConversionDialectInterface {
- public:
- using HALConversionDialectInterface::HALConversionDialectInterface;
-
- void setupConversionTarget(ConversionTarget &target,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter) const override {
- populateStringsToHALPatterns(getDialect()->getContext(), patterns,
- typeConverter);
- };
-};
-
-} // namespace
-
-StringsDialect::StringsDialect(MLIRContext *context)
- : Dialect(getDialectNamespace(), context, TypeID::get<StringsDialect>()) {
- addInterfaces<StringsToVMConversionInterface>();
- addInterfaces<StringsToHALConversionInterface>();
- addInterfaces<StringsInlinerInterface>();
-
- addTypes<StringType, StringTensorType>();
-
-#define GET_OP_LIST
- addOperations<
-#include "iree/compiler/Dialect/Modules/Strings/IR/Ops.cc.inc"
- >();
-}
-
-Type StringsDialect::parseType(DialectAsmParser &parser) const {
- StringRef typeName;
- if (failed(parser.parseKeyword(&typeName))) return {};
- auto type = llvm::StringSwitch<Type>(typeName)
- .Case("string", StringType::get(getContext()))
- .Case("string_tensor", StringTensorType::get(getContext()))
- .Default(nullptr);
-
- if (!type) {
- parser.emitError(parser.getCurrentLocation())
- << "unknown type: " << typeName;
- }
- return type;
-}
-
-void StringsDialect::printType(Type type, DialectAsmPrinter &p) const {
- if (type.isa<StringType>()) {
- p << "string";
- } else if (type.isa<StringTensorType>()) {
- p << "string_tensor";
- } else {
- llvm_unreachable("unknown type");
- }
-}
-
-} // namespace Strings
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/Dialect.h b/iree/compiler/Dialect/Modules/Strings/IR/Dialect.h
deleted file mode 100644
index 80d3b0d..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/Dialect.h
+++ /dev/null
@@ -1,33 +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
-
-#ifndef IREE_COMPILER_TRANSLATION_MODULES_STRINGS_IR_DIALECT_H_
-#define IREE_COMPILER_TRANSLATION_MODULES_STRINGS_IR_DIALECT_H_
-
-#include "iree/compiler/Dialect/IREE/IR/IREETypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/OpDefinition.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace Strings {
-
-class StringsDialect : public Dialect {
- public:
- explicit StringsDialect(MLIRContext *context);
- static StringRef getDialectNamespace() { return "strings"; }
-
- Type parseType(DialectAsmParser &parser) const override;
- void printType(Type type, DialectAsmPrinter &p) const override;
-};
-
-} // namespace Strings
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_TRANSLATION_MODULES_STRINGS_IR_DIALECT_H_
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/Ops.cc b/iree/compiler/Dialect/Modules/Strings/IR/Ops.cc
deleted file mode 100644
index d6e1cf4..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/Ops.cc
+++ /dev/null
@@ -1,19 +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
-
-#include "iree/compiler/Dialect/Modules/Strings/IR/Ops.h"
-
-#include "iree/compiler/Dialect/HAL/IR/HALTypes.h"
-#include "iree/compiler/Dialect/VM/Conversion/ConversionDialectInterface.h"
-#include "llvm/ADT/StringSwitch.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/DialectImplementation.h"
-#include "mlir/IR/SymbolTable.h"
-#include "mlir/Parser.h"
-#include "mlir/Transforms/DialectConversion.h"
-
-#define GET_OP_CLASSES
-#include "iree/compiler/Dialect/Modules/Strings/IR/Ops.cc.inc"
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/Ops.h b/iree/compiler/Dialect/Modules/Strings/IR/Ops.h
deleted file mode 100644
index 64e2c82..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/Ops.h
+++ /dev/null
@@ -1,19 +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
-
-#ifndef IREE_COMPILER_DIALECT_MODULES_STRINGS_IR_OPS_H_
-#define IREE_COMPILER_DIALECT_MODULES_STRINGS_IR_OPS_H_
-
-#include "iree/compiler/Dialect/IREE/IR/IREETypes.h"
-#include "iree/compiler/Dialect/Modules/Strings/IR/Types.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/OpDefinition.h"
-#include "mlir/Interfaces/SideEffectInterfaces.h"
-
-#define GET_OP_CLASSES
-#include "iree/compiler/Dialect/Modules/Strings/IR/Ops.h.inc" // IWYU pragma: export
-
-#endif // IREE_COMPILER_DIALECT_MODULES_STRINGS_IR_OPS_H_
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/Ops.td b/iree/compiler/Dialect/Modules/Strings/IR/Ops.td
deleted file mode 100644
index 5dbe47f..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/Ops.td
+++ /dev/null
@@ -1,125 +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
-
-#ifndef IREE_SAMPLES_STRINGS_MODULES_DIALECT_STRINGS_OPS
-#define IREE_SAMPLES_STRINGS_MODULES_DIALECT_STRINGS_OPS
-
-include "iree/compiler/Dialect/HAL/IR/HALBase.td"
-include "iree/compiler/Dialect/IREE/IR/IREEBase.td"
-include "mlir/IR/OpBase.td"
-include "mlir/Interfaces/SideEffectInterfaces.td"
-
-def STRINGS_ValueTensor : AnyTypeOf<[HAL_BufferView, AnyRankedTensor]>;
-
-def STRINGS_Dialect : Dialect {
- let name = "strings";
- let cppNamespace = "::mlir::iree_compiler::IREE::Strings";
-
- let summary = [{
- A custom dialect supporting string operations.
- }];
- let description = [{
- The ops in this dialect are lowered to vm.imports to support a standard set
- of string operations.
- TODO(suderman): Add a reference to the intermediate string dialect.
- }];
-}
-
-def STRINGS_String : DialectType<
- STRINGS_Dialect,
- CPred<"$_self.isa<IREE::Strings::StringType>()">,
- "string"> {
- let description = [{
- A string type containing a standard ASCII string.
- }];
-}
-
-def STRINGS_StringTensor : DialectType<
- STRINGS_Dialect,
- CPred<"$_self.isa<IREE::Strings::StringTensorType>()">,
- "string_tensor"> {
- let description = [{
- A tensor of string types.
- }];
-}
-
-def STRINGS_I32ToStringOp : Op<STRINGS_Dialect, "i32_to_string", [NoSideEffect]> {
- let summary = [{converts an i32 to a string}];
- let description = [{
- Converts an i32 to its string representation.
- }];
-
- let arguments = (ins I32:$value);
-
- let results = (outs
- STRINGS_String:$result
- );
-}
-
-def STRINGS_ToStringTensorOp : Op<STRINGS_Dialect, "to_string_tensor", [NoSideEffect]> {
- let summary = [{converts a hal buffer to a string tensor}];
- let description = [{
- Converts a hal buffer to a tensor of strings representation.
- }];
-
- let arguments = (ins STRINGS_ValueTensor:$value);
-
- let results = (outs
- STRINGS_StringTensor:$result
- );
-}
-
-def STRINGS_StringTensorToStringOp : Op<STRINGS_Dialect, "string_tensor_to_string", [NoSideEffect]> {
- let summary = [{converts a string tensor to a string}];
- let description = [{
- Converts a string tensor to a string.
- }];
-
- let arguments = (ins STRINGS_StringTensor:$value);
-
- let results = (outs
- STRINGS_String:$result
- );
-}
-
-def STRINGS_GatherOp : Op<STRINGS_Dialect, "gather", [NoSideEffect]> {
- let summary = "Gathers all the strings from a Tensor by index.";
- let description = [{
- Gathers all the strings from a Tensor by index values along the final axis.
- }];
-
- let arguments = (ins STRINGS_StringTensor:$dict,
- STRINGS_ValueTensor:$indices);
-
- let results = (outs
- STRINGS_StringTensor:$result
- );
-}
-
-def STRINGS_ConcatOp : Op<STRINGS_Dialect, "concat", [NoSideEffect]> {
- let summary = "Concatenates a tensor of strings along the last dimension";
-
- let description = [{
- Concatenates the strings in the tensor along the last dimension.
- }];
-
- let arguments = (ins STRINGS_StringTensor:$value);
-
- let results = (outs
- STRINGS_StringTensor:$result
- );
-}
-
-def STRINGS_PrintOp : Op<STRINGS_Dialect, "print"> {
- let summary = "Prints the contents of a string.";
- let description = [{
- Prints the contents of a string.
- }];
-
- let arguments = (ins STRINGS_String:$value);
-}
-
-#endif // IREE_SAMPLES_STRINGS_MODULES_DIALECT_STRINGS_OPS
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/Types.h b/iree/compiler/Dialect/Modules/Strings/IR/Types.h
deleted file mode 100644
index 3e23876..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/Types.h
+++ /dev/null
@@ -1,35 +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
-
-#ifndef IREE_COMPILER_DIALECT_MODULES_STRINGS_IR_TYPES_H_
-#define IREE_COMPILER_DIALECT_MODULES_STRINGS_IR_TYPES_H_
-
-#include "iree/compiler/Dialect/IREE/IR/IREETypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/Interfaces/SideEffectInterfaces.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace Strings {
-
-class StringType : public Type::TypeBase<StringType, Type, TypeStorage> {
- public:
- using Base::Base;
-};
-
-class StringTensorType
- : public Type::TypeBase<StringTensorType, Type, TypeStorage> {
- public:
- using Base::Base;
-};
-
-} // namespace Strings
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_DIALECT_MODULES_STRINGS_IR_TYPES_H_
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/test/BUILD b/iree/compiler/Dialect/Modules/Strings/IR/test/BUILD
deleted file mode 100644
index f1ca284..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/test/BUILD
+++ /dev/null
@@ -1,26 +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("//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(
- ["strings_ops.mlir"],
- include = ["*.mlir"],
- ),
- data = [
- "//iree/tools:IreeFileCheck",
- "//iree/tools:iree-opt",
- ],
-)
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt
deleted file mode 100644
index 47e93c2..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/test/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/Strings/IR/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
- "strings_ops.mlir"
- DATA
- iree::tools::IreeFileCheck
- iree::tools::iree-opt
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/test/strings_ops.mlir b/iree/compiler/Dialect/Modules/Strings/IR/test/strings_ops.mlir
deleted file mode 100644
index 34aa58d..0000000
--- a/iree/compiler/Dialect/Modules/Strings/IR/test/strings_ops.mlir
+++ /dev/null
@@ -1,36 +0,0 @@
-// RUN: iree-opt -split-input-file %s | iree-opt -split-input-file | IreeFileCheck %s
-
-// CHECK-LABEL: @i32ToStringOp
-func @i32ToStringOp(%arg0 : i32) -> !strings.string {
- // CHECK: "strings.i32_to_string"(%arg0) : (i32) -> !strings.string
- %0 = "strings.i32_to_string"(%arg0) : (i32) -> !strings.string
- return %0 : !strings.string
-}
-
-// -----
-
-// CHECK-LABEL: @printOp
-func @printOp(%arg0 : !strings.string) {
- // CHECK: "strings.print"(%arg0) : (!strings.string) -> ()
- "strings.print"(%arg0) : (!strings.string) -> ()
- return
-}
-
-// -----
-
-// CHECK-LABEL: @toStringOp
-func @toStringOp(%arg0 : !hal.buffer_view) -> !strings.string_tensor {
- // CHECK: "strings.to_string_tensor"(%arg0) : (!hal.buffer_view) -> !strings.string_tensor
- %0 = "strings.to_string_tensor"(%arg0) : (!hal.buffer_view) -> !strings.string_tensor
- return %0 : !strings.string_tensor
-}
-
-// -----
-
-// CHECK-LABEL: @stringTensorToStringOp
-func @stringTensorToStringOp(%arg0 : !strings.string_tensor) -> !strings.string {
- // CHECK: "strings.string_tensor_to_string"(%arg0) : (!strings.string_tensor) -> !strings.string
- %0 = "strings.string_tensor_to_string"(%arg0) : (!strings.string_tensor) -> (!strings.string)
- return %0 : !strings.string
-}
-
diff --git a/iree/compiler/Dialect/Modules/Strings/strings.imports.mlir b/iree/compiler/Dialect/Modules/Strings/strings.imports.mlir
deleted file mode 100644
index f3ead5e..0000000
--- a/iree/compiler/Dialect/Modules/Strings/strings.imports.mlir
+++ /dev/null
@@ -1,43 +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
-
-// 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 (strings/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 @strings {
-
-// Returns the string representation of an i32.
-// Maps to the IREE::Strings::I32ToString.
-vm.import @i32_to_string(%value : i32) -> !vm.ref<!strings.string>
-attributes {nosideeffects}
-
-// Elementwise conversion of a tensor of values to a tensor of strings.
-// Maps to the IREE::Strings::ToStringTensor.
-vm.import @to_string_tensor(%value : !vm.ref<!hal.buffer_view>) -> !vm.ref<!strings.string_tensor>
-attributes {nosideeffects}
-
-// Prints the contents of a string.
-// Maps to the IREE::Strings::Print.
-vm.import @print(%value : !vm.ref<!strings.string>)
-
-// Converts the contents of a StringTensor to a String
-// Maps to the IREE::Strings::StringTensortoString.
-vm.import @string_tensor_to_string(%value : !vm.ref<!strings.string_tensor>) -> !vm.ref<!strings.string>
-
-// Gathers all the strings from a Tensor by ID
-// Maps to the IREE::Strings::Gather.
-vm.import @gather(%value1 : !vm.ref<!strings.string_tensor>, %value2 : !vm.ref<!hal.buffer_view>) -> !vm.ref<!strings.string_tensor>
-
-// Concatenates the strings in the tensor along the last dimension
-// Maps to the IREE::Strings::Concat.
-vm.import @concat(%value : !vm.ref<!strings.string_tensor>) -> !vm.ref<!strings.string_tensor>
-
-} // vm.module
diff --git a/iree/compiler/Dialect/Modules/TensorList/BUILD b/iree/compiler/Dialect/Modules/TensorList/BUILD
deleted file mode 100644
index b28f639..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/BUILD
+++ /dev/null
@@ -1,22 +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")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-c_embed_data(
- name = "tensorlist_imports",
- srcs = ["tensorlist.imports.mlir"],
- c_file_output = "tensorlist.imports.c",
- flatten = True,
- h_file_output = "tensorlist.imports.h",
- identifier = "iree_tensorlist_imports",
-)
diff --git a/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
deleted file mode 100644
index b9d2f43..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/TensorList/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_c_embed_data(
- NAME
- tensorlist_imports
- SRCS
- "tensorlist.imports.mlir"
- C_FILE_OUTPUT
- "tensorlist.imports.c"
- H_FILE_OUTPUT
- "tensorlist.imports.h"
- IDENTIFIER
- "iree_tensorlist_imports"
- FLATTEN
- PUBLIC
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/BUILD b/iree/compiler/Dialect/Modules/TensorList/Conversion/BUILD
deleted file mode 100644
index f5be5a7..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/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
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-cc_library(
- name = "Conversion",
- srcs = [
- "ConversionPatterns.cpp",
- ],
- hdrs = [
- "ConversionPatterns.h",
- ],
- deps = [
- "//iree/compiler/Dialect/HAL/Conversion",
- "//iree/compiler/Dialect/HAL/IR",
- "//iree/compiler/Dialect/HAL/Utils",
- "//iree/compiler/Dialect/Modules/TensorList/IR",
- "//iree/compiler/Dialect/VM/Conversion",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:Transforms",
- ],
-)
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/Conversion/CMakeLists.txt
deleted file mode 100644
index 4ca4f31..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/TensorList/Conversion/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
- Conversion
- HDRS
- "ConversionPatterns.h"
- SRCS
- "ConversionPatterns.cpp"
- DEPS
- MLIRPass
- MLIRTransforms
- iree::compiler::Dialect::HAL::Conversion
- iree::compiler::Dialect::HAL::IR
- iree::compiler::Dialect::HAL::Utils
- iree::compiler::Dialect::Modules::TensorList::IR
- iree::compiler::Dialect::VM::Conversion
- PUBLIC
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/ConversionPatterns.cpp b/iree/compiler/Dialect/Modules/TensorList/Conversion/ConversionPatterns.cpp
deleted file mode 100644
index 54b2c3d..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/ConversionPatterns.cpp
+++ /dev/null
@@ -1,172 +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/Dialect/Modules/TensorList/Conversion/ConversionPatterns.h"
-
-#include "iree/compiler/Dialect/HAL/Conversion/ConversionTarget.h"
-#include "iree/compiler/Dialect/HAL/IR/HALOps.h"
-#include "iree/compiler/Dialect/HAL/Utils/TypeUtils.h"
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.h"
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.h"
-#include "iree/compiler/Dialect/VM/Conversion/ImportUtils.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace TensorList {
-
-namespace {
-
-Value getBufferView(Operation *srcOp, Value srcOperand, Value dstOperand,
- ConversionPatternRewriter &rewriter) {
- auto operand = IREE::HAL::TensorRewriteAdaptor::getChecked(
- srcOp->getLoc(), srcOperand, dstOperand, rewriter);
- if (!operand.hasValue()) {
- srcOp->emitOpError() << "unable to create adaptor for operand";
- return nullptr;
- }
- auto bufferView = operand->getBufferView();
- if (!bufferView) {
- srcOp->emitOpError() << "unable to get buffer view for operand";
- return nullptr;
- }
-
- return bufferView;
-}
-
-class ReserveOpConversion
- : public OpConversionPattern<IREE::TensorList::ReserveTensor> {
- public:
- ReserveOpConversion(MLIRContext *ctx, TypeConverter &converter)
- : OpConversionPattern(ctx) {}
-
- LogicalResult matchAndRewrite(
- IREE::TensorList::ReserveTensor reserveOp,
- llvm::ArrayRef<Value> newOperands,
- ConversionPatternRewriter &rewriter) const override {
- auto elementTy = reserveOp.element_type();
- auto element_value = IREE::HAL::getElementTypeValue(elementTy).getValue();
-
- auto operand0 = getBufferView(reserveOp, reserveOp.getOperand(0),
- newOperands[0], rewriter);
- auto operand1 = getBufferView(reserveOp, reserveOp.getOperand(1),
- newOperands[1], rewriter);
-
- if (!operand0 || !operand1) {
- return failure();
- }
-
- rewriter.replaceOpWithNewOp<IREE::TensorList::Reserve>(
- reserveOp,
- IREE::TensorList::TensorListType::get(reserveOp.getContext()), operand0,
- operand1, rewriter.getI32IntegerAttr(element_value));
- return success();
- }
-};
-
-class ConcatOpConversion
- : public OpConversionPattern<IREE::TensorList::ConcatTensor> {
- public:
- ConcatOpConversion(MLIRContext *ctx, TypeConverter &converter)
- : OpConversionPattern(ctx) {}
-
- LogicalResult matchAndRewrite(
- IREE::TensorList::ConcatTensor concatOp,
- llvm::ArrayRef<Value> newOperands,
- ConversionPatternRewriter &rewriter) const override {
- auto device =
- rewriter.createOrFold<IREE::HAL::ExSharedDeviceOp>(concatOp.getLoc());
- auto allocator =
- rewriter.create<IREE::HAL::DeviceAllocatorOp>(concatOp.getLoc(), device)
- .getResult();
-
- auto newConcatOp = rewriter.createOrFold<IREE::TensorList::Concat>(
- concatOp.getLoc(),
- IREE::HAL::BufferViewType::get(rewriter.getContext()), allocator,
- newOperands[0]);
-
- auto bufferOp = rewriter.createOrFold<IREE::HAL::BufferViewBufferOp>(
- newConcatOp.getLoc(), IREE::HAL::BufferType::get(rewriter.getContext()),
- newConcatOp);
-
- rewriter.replaceOp(concatOp, bufferOp);
- return success();
- }
-};
-
-class StackOpConversion
- : public OpConversionPattern<IREE::TensorList::StackTensor> {
- public:
- StackOpConversion(MLIRContext *ctx, TypeConverter &converter)
- : OpConversionPattern(ctx) {}
-
- LogicalResult matchAndRewrite(
- IREE::TensorList::StackTensor stackOp, llvm::ArrayRef<Value> newOperands,
- ConversionPatternRewriter &rewriter) const override {
- auto device =
- rewriter.createOrFold<IREE::HAL::ExSharedDeviceOp>(stackOp.getLoc());
- auto allocator =
- rewriter.create<IREE::HAL::DeviceAllocatorOp>(stackOp.getLoc(), device)
- .getResult();
-
- auto operand1 =
- getBufferView(stackOp, stackOp.getOperand(1), newOperands[1], rewriter);
- if (!operand1) return failure();
-
- auto newStackOp = rewriter.createOrFold<IREE::TensorList::Stack>(
- stackOp.getLoc(), IREE::HAL::BufferViewType::get(rewriter.getContext()),
- allocator, newOperands[0], operand1);
-
- auto bufferOp = rewriter.createOrFold<IREE::HAL::BufferViewBufferOp>(
- stackOp.getLoc(), IREE::HAL::BufferType::get(rewriter.getContext()),
- newStackOp);
-
- rewriter.replaceOp(stackOp, bufferOp);
- return success();
- }
-};
-
-} // namespace
-
-void populateTensorListToHALPatterns(MLIRContext *context,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter) {
- patterns.insert<HALOpConversion<IREE::TensorList::FromTensor,
- IREE::TensorList::FromTensor>>(context,
- typeConverter);
- patterns.insert<
- HALOpConversion<IREE::TensorList::GetItem, IREE::TensorList::GetItem>>(
- context, typeConverter);
- patterns.insert<
- HALOpConversion<IREE::TensorList::SetItem, IREE::TensorList::SetItem>>(
- context, typeConverter);
- patterns.insert<ConcatOpConversion>(context, typeConverter);
- patterns.insert<ReserveOpConversion>(context, typeConverter);
- patterns.insert<StackOpConversion>(context, typeConverter);
-}
-
-void populateTensorListToVMPatterns(MLIRContext *context,
- SymbolTable &importSymbols,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter) {
- patterns.insert<VMImportOpConversion<IREE::TensorList::Reserve>>(
- context, importSymbols, typeConverter, "tensorlist.reserve");
- patterns.insert<VMImportOpConversion<IREE::TensorList::GetItem>>(
- context, importSymbols, typeConverter, "tensorlist.get_item");
- patterns.insert<VMImportOpConversion<IREE::TensorList::SetItem>>(
- context, importSymbols, typeConverter, "tensorlist.set_item");
- patterns.insert<VMImportOpConversion<IREE::TensorList::FromTensor>>(
- context, importSymbols, typeConverter, "tensorlist.from_tensor");
- patterns.insert<VMImportOpConversion<IREE::TensorList::Concat>>(
- context, importSymbols, typeConverter, "tensorlist.concat");
- patterns.insert<VMImportOpConversion<IREE::TensorList::Stack>>(
- context, importSymbols, typeConverter, "tensorlist.stack");
-}
-
-} // namespace TensorList
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/ConversionPatterns.h b/iree/compiler/Dialect/Modules/TensorList/Conversion/ConversionPatterns.h
deleted file mode 100644
index 1a09c6d..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/ConversionPatterns.h
+++ /dev/null
@@ -1,36 +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_DIALECT_MODULES_TENSORLIST_CONVERSION_CONVERSION_PATTERNS_H_
-#define IREE_COMPILER_DIALECT_MODULES_TENSORLIST_CONVERSION_CONVERSION_PATTERNS_H_
-
-#include "mlir/Pass/Pass.h"
-#include "mlir/Transforms/DialectConversion.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace TensorList {
-
-// Populates conversion patterns from the TensorList dialect to the HAL
-// dialect.
-void populateTensorListToHALPatterns(MLIRContext *context,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter);
-
-// Populates conversion patterns from the TensorList dialect to the VM
-// dialect.
-void populateTensorListToVMPatterns(MLIRContext *context,
- SymbolTable &importSymbols,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter);
-
-} // namespace TensorList
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_DIALECT_MODULES_TENSORLIST_CONVERSION_CONVERSION_PATTERNS_H_
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/README.md b/iree/compiler/Dialect/Modules/TensorList/Conversion/README.md
deleted file mode 100644
index d927ac9..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-TensorList is a module in IREE, which means that it hooks into IREE's conversion
-flow. There are two main conversions that happen during IREE compilation, which
-have corresponding directories in `iree/compiler/Dialect/HAL/Conversion/`,
-namely FlowToHAL and HALToVM.
-
-For our purposes here, FlowToHAL does the following type conversions:
-
-- converts from `tensor<....>` to `!hal.buffer_view`
-
-- converts from the frontend representation of TensorList (e.g.
- `!tf_tensorlist.list`) to `!tensorlist.list` (this dialect).
-
-For our purposes here, HALToVM maps ops to VM-level calls into a custom module.
-
-This dialect hooks into those conversion processes. Unfortunately, the FlowToHAL
-step requires taking a dependency on tf_tensorlist which depends on TensorFlow.
-We don't want to take a dependency on TensorFlow here, so we put the FlowToHAL
-step in the `tf_tensorlist` dialect.
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/BUILD b/iree/compiler/Dialect/Modules/TensorList/Conversion/test/BUILD
deleted file mode 100644
index 23975f9..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/BUILD
+++ /dev/null
@@ -1,29 +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("//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(
- [
- "convert_hal_to_vm.mlir",
- "convert_to_hal.mlir",
- ],
- include = ["*.mlir"],
- ),
- data = [
- "//iree/tools:IreeFileCheck",
- "//iree/tools:iree-opt",
- ],
-)
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt
deleted file mode 100644
index 7b21210..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/TensorList/Conversion/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
- "convert_hal_to_vm.mlir"
- "convert_to_hal.mlir"
- DATA
- iree::tools::IreeFileCheck
- iree::tools::iree-opt
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/convert_hal_to_vm.mlir b/iree/compiler/Dialect/Modules/TensorList/Conversion/test/convert_hal_to_vm.mlir
deleted file mode 100644
index 3f011a4..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/convert_hal_to_vm.mlir
+++ /dev/null
@@ -1,51 +0,0 @@
-// RUN: iree-opt <%s -iree-vm-conversion -split-input-file | IreeFileCheck %s
-
-// CHECK-LABEL: @Reserve
-func @Reserve(%element_shape: !hal.buffer_view, %num_elements: !hal.buffer_view) -> !tensorlist.list {
- // CHECK: vm.call @tensorlist.reserve
- %0 = "tensorlist.Reserve"(%element_shape, %num_elements) { element_type = 50331680 : i32 } : (!hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- return %0 : !tensorlist.list
-}
-// CHECK: vm.import @tensorlist.reserve
-
-// -----
-
-// CHECK-LABEL: @GetItem
-func @GetItem(%list: !tensorlist.list, %index: !hal.buffer_view) -> !hal.buffer_view {
- // CHECK: vm.call @tensorlist.get_item
- %0 = "tensorlist.GetItem"(%list, %index) : (!tensorlist.list, !hal.buffer_view) -> !hal.buffer_view
- return %0 : !hal.buffer_view
-}
-// CHECK: vm.import @tensorlist.get_item
-
-// -----
-
-// CHECK-LABEL: @SetItem
-func @SetItem(%list: !tensorlist.list, %index: !hal.buffer_view, %item: !hal.buffer_view) -> !tensorlist.list{
- // CHECK: vm.call @tensorlist.set_item
- %0 = "tensorlist.SetItem"(%list, %index, %item) : (!tensorlist.list, !hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- return %0 : !tensorlist.list
-}
-// CHECK: vm.import @tensorlist.set_item
-
-// -----
-
-// CHECK-LABEL: @Stack
-func @Stack(%list: !tensorlist.list, %num_elements: !hal.buffer_view) -> !hal.buffer_view {
- %device = hal.ex.shared_device : !hal.device
- %allocator = hal.device.allocator<%device : !hal.device> : !hal.allocator
- // CHECK: vm.call @tensorlist.stack
- %0 = "tensorlist.Stack"(%allocator, %list, %num_elements) : (!hal.allocator, !tensorlist.list, !hal.buffer_view) -> !hal.buffer_view
- return %0 : !hal.buffer_view
-}
-
-// -----
-
-// CHECK-LABEL: @Concat
-func @Concat(%list: !tensorlist.list) -> !hal.buffer_view {
- %device = hal.ex.shared_device : !hal.device
- %allocator = hal.device.allocator<%device : !hal.device> : !hal.allocator
- // CHECK: vm.call @tensorlist.concat
- %0 = "tensorlist.Concat"(%allocator, %list) : (!hal.allocator, !tensorlist.list) -> !hal.buffer_view
- return %0 : !hal.buffer_view
-}
diff --git a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/convert_to_hal.mlir b/iree/compiler/Dialect/Modules/TensorList/Conversion/test/convert_to_hal.mlir
deleted file mode 100644
index b4159ba..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/Conversion/test/convert_to_hal.mlir
+++ /dev/null
@@ -1,81 +0,0 @@
-
-// RUN: iree-opt --iree-convert-to-hal %s --split-input-file | IreeFileCheck %s
-
-// CHECK: @Reserve
-func @Reserve(%arg0: tensor<0xi32>, %arg1: tensor<i32>) -> !tensorlist.list {
- // CHECK: %c16777248_i32 = constant 16777248 : i32
- // CHECK: %[[VIEW0:.+]] = hal.buffer_view.create %arg0, element_type = %c16777248_i32, shape = [%c0]
- // CHECK: %c16777248_i32_0 = constant 16777248 : i32
- // CHECK: %[[VIEW1:.+]] = hal.buffer_view.create %arg1, element_type = %c16777248_i32_0, shape = []
- // CHECK: %[[LIST:.+]] = "tensorlist.Reserve"(%[[VIEW0]], %[[VIEW1]]) {element_type = 50331680 : i32}
- %0 = "tensorlist.Reserve.Tensor"(%arg0, %arg1) {element_type = f32} : (tensor<0xi32>, tensor<i32>) -> !tensorlist.list
-
- // CHECK: return %[[LIST]]
- return %0 : !tensorlist.list
-}
-
-// -----
-
-// CHECK: @FromTensorList
-func @FromTensorList(%arg0: tensor<10xi32>) -> !tensorlist.list {
- // CHECK: [[VIEW:%.+]] = hal.buffer_view.create %arg0
- // CHECK: [[RET:%.+]] = "tensorlist.FromTensor"([[VIEW]])
- %0 = "tensorlist.FromTensor"(%arg0) : (tensor<10xi32>) -> !tensorlist.list
-
- // CHECK: return [[RET]]
- return %0 : !tensorlist.list
-}
-
-// -----
-
-// CHECK: @SetItem
-func @SetItem(%arg0: !tensorlist.list, %arg1: tensor<i32>, %arg2: tensor<f32>) -> !tensorlist.list {
- // CHECK: [[VIEW0:%.+]] = hal.buffer_view.create %arg1
- // CHECK: [[VIEW1:%.+]] = hal.buffer_view.create %arg2
- // CHECK: [[RET:%.+]] = "tensorlist.SetItem"(%arg0, [[VIEW0]], [[VIEW1]])
-
- %0 = "tensorlist.SetItem"(%arg0, %arg1, %arg2) : (!tensorlist.list, tensor<i32>, tensor<f32>) -> !tensorlist.list
- // CHECK: return [[RET]]
- return %0 : !tensorlist.list
-}
-
-// -----
-
-// CHECK: @GetItem
-func @GetItem(%arg0: !tensorlist.list, %arg1: tensor<i32>) -> tensor<f32> {
- // CHECK: [[VIEW:%.+]] = hal.buffer_view.create %arg1
- // CHECK: [[ITEM:%.+]] = "tensorlist.GetItem"(%arg0, [[VIEW]])
- // CHECK: [[BUF:%.+]] = hal.buffer_view.buffer [[ITEM]]
- %0 = "tensorlist.GetItem"(%arg0, %arg1) : (!tensorlist.list, tensor<i32>) -> tensor<f32>
-
- // CHECK: return [[BUF]]
- return %0 : tensor<f32>
-}
-
-// -----
-
-// CHECK: @Stack
-func @Stack(%arg0: !tensorlist.list, %arg1: tensor<i32>) -> tensor<1xf32> {
- // CHECK-DAG: [[ALL:%.+]] = hal.device.allocator
- // CHECK-DAG: [[VIEW:%.+]] = hal.buffer_view.create %arg1
- // CHECK-DAG: [[RES:%.+]] = "tensorlist.Stack"([[ALL]], %arg0, [[VIEW]])
- // CHECK-DAG: [[BUF:%.+]] = hal.buffer_view.buffer [[RES]]
- %0 = "tensorlist.Stack.Tensor"(%arg0, %arg1) : (!tensorlist.list, tensor<i32>) -> tensor<1xf32>
-
- // CHECK: return [[BUF]]
- return %0 : tensor<1xf32>
-}
-
-// -----
-
-// CHECK: @Concat
-func @Concat(%arg0: !tensorlist.list) -> tensor<1xf32> {
- // CHECK: [[ALL:%.+]] = hal.device.allocator
- // CHECK: [[RES:%.+]] = "tensorlist.Concat"([[ALL]], %arg0)
- // CHECK: [[BUF:%.+]] = hal.buffer_view.buffer [[RES]]
- %0 = "tensorlist.Concat.Tensor"(%arg0) : (!tensorlist.list) -> tensor<1xf32>
-
- // CHECK: return [[BUF]]
- return %0 : tensor<1xf32>
-}
-
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/BUILD b/iree/compiler/Dialect/Modules/TensorList/IR/BUILD
deleted file mode 100644
index d8591d5..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/BUILD
+++ /dev/null
@@ -1,114 +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_tablegen_doc.bzl", "iree_tablegen_doc")
-load("//build_tools/bazel:tblgen.bzl", "gentbl_cc_library")
-load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-exports_files(["TensorListBase.td"])
-
-filegroup(
- name = "td_files",
- srcs = enforce_glob(
- [
- "TensorListBase.td",
- "TensorListOps.td",
- ],
- include = ["*.td"],
- ),
-)
-
-cc_library(
- name = "IR",
- srcs = [
- "TensorListOps.cpp",
- "TensorListTypes.cpp",
- ],
- hdrs = [
- "TensorListOps.h",
- "TensorListOps.h.inc",
- "TensorListTypes.h",
- ],
- textual_hdrs = [
- "TensorListOps.cpp.inc",
- ],
- deps = [
- ":TensorListOpsGen",
- "//iree/compiler/Dialect/HAL/IR",
- "//iree/compiler/Dialect/IREE/IR",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Parser",
- "@llvm-project//mlir:StandardOps",
- "@llvm-project//mlir:Support",
- "@llvm-project//mlir:TransformUtils",
- ],
-)
-
-cc_library(
- name = "TensorListDialect",
- srcs = ["TensorListDialect.cpp"],
- hdrs = ["TensorListDialect.h"],
- deps = [
- ":IR",
- "//iree/compiler/Dialect/HAL/Conversion",
- "//iree/compiler/Dialect/HAL/IR",
- "//iree/compiler/Dialect/IREE/IR",
- "//iree/compiler/Dialect/Modules/TensorList:tensorlist_imports",
- "//iree/compiler/Dialect/Modules/TensorList/Conversion",
- "//iree/compiler/Dialect/VM/Conversion",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Parser",
- "@llvm-project//mlir:TransformUtils",
- ],
-)
-
-gentbl_cc_library(
- name = "TensorListOpsGen",
- tbl_outs = [
- (
- ["-gen-op-decls"],
- "TensorListOps.h.inc",
- ),
- (
- ["-gen-op-defs"],
- "TensorListOps.cpp.inc",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "TensorListOps.td",
- td_srcs = [
- ":td_files",
- "//iree/compiler/Dialect/IREE/IR:td_files",
- "//iree/compiler/Dialect/HAL/IR:td_files",
- "@llvm-project//mlir:StdOpsTdFiles",
- ],
-)
-
-iree_tablegen_doc(
- name = "TensorListDialectDocGen",
- tbl_outs = [
- (
- ["-gen-dialect-doc"],
- "TensorListDialect.md",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "TensorListOps.td",
- td_srcs = [
- ":td_files",
- "//iree/compiler/Dialect/IREE/IR:td_files",
- "//iree/compiler/Dialect/HAL/IR:td_files",
- "@llvm-project//mlir:StdOpsTdFiles",
- ],
-)
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt
deleted file mode 100644
index b3f56e7..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/CMakeLists.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/TensorList/IR/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
- IR
- HDRS
- "TensorListOps.h"
- "TensorListOps.h.inc"
- "TensorListTypes.h"
- TEXTUAL_HDRS
- "TensorListOps.cpp.inc"
- SRCS
- "TensorListOps.cpp"
- "TensorListTypes.cpp"
- DEPS
- LLVMSupport
- MLIRIR
- MLIRParser
- MLIRStandard
- MLIRSupport
- MLIRTransformUtils
- iree::compiler::Dialect::HAL::IR
- iree::compiler::Dialect::IREE::IR
- PUBLIC
-)
-
-iree_cc_library(
- NAME
- TensorListDialect
- HDRS
- "TensorListDialect.h"
- SRCS
- "TensorListDialect.cpp"
- DEPS
- ::IR
- LLVMSupport
- MLIRIR
- MLIRParser
- MLIRTransformUtils
- iree::compiler::Dialect::HAL::Conversion
- iree::compiler::Dialect::HAL::IR
- iree::compiler::Dialect::IREE::IR
- iree::compiler::Dialect::Modules::TensorList::Conversion
- iree::compiler::Dialect::Modules::TensorList::tensorlist_imports
- iree::compiler::Dialect::VM::Conversion
- PUBLIC
-)
-
-iree_tablegen_library(
- NAME
- TensorListOpsGen
- TD_FILE
- "TensorListOps.td"
- OUTS
- -gen-op-decls TensorListOps.h.inc
- -gen-op-defs TensorListOps.cpp.inc
-)
-
-iree_tablegen_doc(
- NAME
- TensorListDialectDocGen
- TD_FILE
- "TensorListOps.td"
- OUTS
- -gen-dialect-doc TensorListDialect.md
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListBase.td b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListBase.td
deleted file mode 100644
index de99f50..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListBase.td
+++ /dev/null
@@ -1,38 +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_DIALECT_MODULES_TENSORLIST_BASE
-#define IREE_DIALECT_MODULES_TENSORLIST_BASE
-
-include "iree/compiler/Dialect/IREE/IR/IREEBase.td"
-
-def TensorList_Dialect : Dialect {
- let name = "tensorlist";
- let cppNamespace = "::mlir::iree_compiler::IREE::TensorList";
-
- let summary = [{
- A dialect for implementing TensorFlow's TensorList data structure.
- }];
- let description = [{
- This dialect contains ops that map 1:1 to the corresponding IREE native
- module.
-
- This dialect mimics TensorFlow's TensorList op set. It provides a
- a straightforward implementation of those semantics.
- }];
-}
-
-def TensorList_TensorList : DialectType<
- TensorList_Dialect,
- CPred<"$_self.isa<IREE::TensorList::TensorListType>()">,
- "tensorlist.list"> {
- let description = [{
- IREE VM type representing a TensorList.
- }];
-}
-
-
-#endif // IREE_DIALECT_MODULES_TENSORLIST_BASE
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp
deleted file mode 100644
index 9975127..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp
+++ /dev/null
@@ -1,124 +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/Dialect/Modules/TensorList/IR/TensorListDialect.h"
-
-#include "iree/compiler/Dialect/HAL/Conversion/ConversionDialectInterface.h"
-#include "iree/compiler/Dialect/HAL/IR/HALTypes.h"
-#include "iree/compiler/Dialect/Modules/TensorList/Conversion/ConversionPatterns.h"
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.h"
-#include "iree/compiler/Dialect/Modules/TensorList/tensorlist.imports.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.h"
-#include "mlir/Transforms/DialectConversion.h"
-#include "mlir/Transforms/InliningUtils.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace TensorList {
-
-namespace {
-
-struct TensorListInlinerInterface : public DialectInlinerInterface {
- using DialectInlinerInterface::DialectInlinerInterface;
-
- bool isLegalToInline(Operation *call, Operation *callable,
- bool wouldBeCloned) const final {
- // Sure!
- return true;
- }
-
- bool isLegalToInline(Region *dest, Region *src, bool wouldBeCloned,
- BlockAndValueMapping &valueMapping) const final {
- // Sure!
- return true;
- }
-
- bool isLegalToInline(Operation *op, Region *dest, bool wouldBeCloned,
- BlockAndValueMapping &valueMapping) const final {
- // Sure!
- return true;
- }
-};
-
-class TensorListToHALConversionInterface
- : public HALConversionDialectInterface {
- public:
- using HALConversionDialectInterface::HALConversionDialectInterface;
-
- void setupConversionTarget(ConversionTarget &target,
- OwningRewritePatternList &patterns,
- TypeConverter &typeConverter) const override {
- populateTensorListToHALPatterns(getDialect()->getContext(), patterns,
- typeConverter);
- };
-};
-
-class TensorListToVMConversionInterface : public VMConversionDialectInterface {
- public:
- using VMConversionDialectInterface::VMConversionDialectInterface;
-
- OwningModuleRef parseVMImportModule() const override {
- return mlir::parseSourceString(
- StringRef(iree_tensorlist_imports_create()->data,
- iree_tensorlist_imports_create()->size),
- getDialect()->getContext());
- }
-
- void populateVMConversionPatterns(
- SymbolTable &importSymbols, OwningRewritePatternList &patterns,
- TypeConverter &typeConverter) const override {
- populateTensorListToVMPatterns(getDialect()->getContext(), importSymbols,
- patterns, typeConverter);
- }
-};
-
-} // namespace
-
-TensorListDialect::TensorListDialect(MLIRContext *context)
- : Dialect(getDialectNamespace(), context,
- TypeID::get<TensorListDialect>()) {
- addInterfaces<TensorListToHALConversionInterface>();
- addInterfaces<TensorListToVMConversionInterface>();
- addInterfaces<TensorListInlinerInterface>();
-
- addTypes<TensorListType>();
-
-#define GET_OP_LIST
- addOperations<
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.cpp.inc"
- >();
-}
-
-Type TensorListDialect::parseType(DialectAsmParser &parser) const {
- StringRef typeName;
- if (failed(parser.parseKeyword(&typeName))) return {};
- auto type = llvm::StringSwitch<Type>(typeName)
- .Case("list", TensorListType::get(getContext()))
- .Default(nullptr);
- if (!type) {
- parser.emitError(parser.getCurrentLocation())
- << "unknown type: " << typeName;
- }
- return type;
-}
-
-void TensorListDialect::printType(Type type, DialectAsmPrinter &p) const {
- if (type.isa<TensorListType>()) {
- p << "list";
- } else {
- llvm_unreachable("unknown type");
- }
-}
-
-} // namespace TensorList
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.h b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.h
deleted file mode 100644
index 6e9b9ad..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.h
+++ /dev/null
@@ -1,33 +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_DIALECT_MODULES_TENSORLIST_IR_TENSORLIST_DIALECT_H_
-#define IREE_COMPILER_DIALECT_MODULES_TENSORLIST_IR_TENSORLIST_DIALECT_H_
-
-#include "iree/compiler/Dialect/IREE/IR/IREETypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/OpDefinition.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace TensorList {
-
-class TensorListDialect : public Dialect {
- public:
- explicit TensorListDialect(MLIRContext *context);
- static StringRef getDialectNamespace() { return "tensorlist"; }
-
- Type parseType(DialectAsmParser &parser) const override;
- void printType(Type type, DialectAsmPrinter &p) const override;
-};
-
-} // namespace TensorList
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_DIALECT_MODULES_TENSORLIST_IR_TENSORLIST_DIALECT_H_
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.cpp b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.cpp
deleted file mode 100644
index 78298a4..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.cpp
+++ /dev/null
@@ -1,13 +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/Dialect/Modules/TensorList/IR/TensorListOps.h"
-
-#include "iree/compiler/Dialect/HAL/IR/HALTypes.h"
-#include "mlir/IR/Builders.h"
-
-#define GET_OP_CLASSES
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.cpp.inc"
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.h b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.h
deleted file mode 100644
index 434b047..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.h
+++ /dev/null
@@ -1,16 +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_DIALECT_MODULES_TENSORLIST_IR_TENSORLISTOPS_H_
-#define IREE_COMPILER_DIALECT_MODULES_TENSORLIST_IR_TENSORLISTOPS_H_
-
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.h"
-#include "mlir/IR/OpDefinition.h"
-
-#define GET_OP_CLASSES
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.h.inc" // IWYU pragma: export
-
-#endif // IREE_COMPILER_DIALECT_MODULES_TENSORLIST_IR_TENSORLISTOPS_H_
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.td b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.td
deleted file mode 100644
index fe4c50e..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListOps.td
+++ /dev/null
@@ -1,174 +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_DIALECT_MODULES_TENSORLIST_OPS
-#define IREE_DIALECT_MODULES_TENSORLIST_OPS
-
-include "iree/compiler/Dialect/IREE/IR/IREEBase.td"
-include "iree/compiler/Dialect/HAL/IR/HALBase.td"
-include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListBase.td"
-include "mlir/IR/OpBase.td"
-
-def TensorList_TensorOrBuffer : AnyTypeOf<[HAL_BufferView, AnyRankedTensor]>;
-
-def TensorList_ReserveTensor : Op<TensorList_Dialect, "Reserve.Tensor"> {
- let summary = [{Create a new tensorlist with a given capacity.}];
- let description = [{
- Create a new tensorlist with a given capacity.
- }];
-
- let arguments = (ins
- AnyRankedTensor:$element_shape,
- AnyRankedTensor:$count,
- TypeAttr:$element_type
- );
-
- let results = (outs
- TensorList_TensorList:$list
- );
-}
-
-def TensorList_Reserve : Op<TensorList_Dialect, "Reserve"> {
- let summary = [{Create a new tensorlist with a given capacity.}];
- let description = [{
- Create a new tensorlist with a given capacity.
- }];
-
- let arguments = (ins
- HAL_BufferView:$element_shape,
- // TODO(silvasean): Convert to `I32:$count` instead.
- HAL_BufferView:$count,
- HAL_ElementTypeAttr:$element_type
- );
-
- let results = (outs
- TensorList_TensorList:$list
- );
-}
-
-def TensorList_GetItem : Op<TensorList_Dialect, "GetItem"> {
- let summary = [{Gets an item out of a tensorlist.}];
- let description = [{
- Gets an item out of a tensorlist.
- }];
-
- let arguments = (ins
- TensorList_TensorList:$list,
- // TODO(silvasean): Convert to `I32:$index` instead.
- TensorList_TensorOrBuffer:$index
- );
-
- let results = (outs TensorList_TensorOrBuffer:$item);
-}
-
-def TensorList_SetItem : Op<TensorList_Dialect, "SetItem"> {
- let summary = [{Sets an item of a tensorlist.}];
- let description = [{
- Sets an item of a tensorlist, returning a new tensorlist `new_list`
- reflecting the updated value. Does not mutate `list`.
- }];
-
- let arguments = (ins
- TensorList_TensorList:$list,
- // TODO(silvasean): Convert to `I32:$index` instead.
- TensorList_TensorOrBuffer:$index,
- TensorList_TensorOrBuffer:$item
- );
-
- let results = (outs
- TensorList_TensorList:$new_list
- );
-}
-
-def TensorList_FromTensor : Op<TensorList_Dialect, "FromTensor"> {
- let summary = "Creates a tensorlist by slicing along the first dimension";
- let description = [{
- The tensor `tensor` will be sliced along its first dimension, resulting in
- a tensorlist `list` of length equal to `tensor`'s leading dimension.
- }];
- let arguments = (ins
- TensorList_TensorOrBuffer:$tensor
- );
- let results = (outs
- TensorList_TensorList:$list
- );
-}
-
-def TensorList_StackTensor : Op<TensorList_Dialect, "Stack.Tensor"> {
- let summary = "Creates a tensor by stacking the tensors in the tensorlist";
- let description = [{
- Creates a new tensor `tensor` by stacking the tensors in `list`.
- The resulting tensor has a leading dimension equal to the length of `list`.
-
- Requires the list to be non-empty.
- Requires all tensors contained in `list` to be the same shape.
- }];
- let arguments = (ins
- TensorList_TensorList:$list,
- AnyRankedTensor:$num_elements
- );
- let results = (outs
- AnyRankedTensor:$tensor
- );
-}
-
-def TensorList_Stack : Op<TensorList_Dialect, "Stack"> {
- let summary = "Creates a tensor by stacking the tensors in the tensorlist";
- let description = [{
- Creates a new tensor `tensor` by stacking the tensors in `list`.
- The resulting tensor has a leading dimension equal to the length of `list`.
-
- Requires the list to be non-empty.
- Requires all tensors contained in `list` to be the same shape.
- }];
- let arguments = (ins
- HAL_Allocator:$allocator,
- TensorList_TensorList:$list,
- HAL_BufferView:$num_elements
- );
- let results = (outs
- HAL_BufferView:$tensor
- );
-}
-
-def TensorList_ConcatTensor : Op<TensorList_Dialect, "Concat.Tensor"> {
- let summary = "Creates a tensor by concatenate the tensors in the tensorlist";
- let description = [{
- Creates a new tensor `tensor` by concatenating the tensors in `list` along
- the leading dimension.
-
- Requires the list to be non-empty.
- Requires all tensors contained in `list` to have the same dimensions along
- the non-leading axes.
- }];
- let arguments = (ins
- TensorList_TensorList:$list
- );
- let results = (outs
- AnyRankedTensor:$tensor
- );
-}
-
-def TensorList_Concat : Op<TensorList_Dialect, "Concat"> {
- let summary = "Creates a tensor by concatenate the tensors in the tensorlist";
- let description = [{
- Creates a new tensor `tensor` by concatenating the tensors in `list` along
- the leading dimension.
-
- Requires the list to be non-empty.
- Requires all tensors contained in `list` to have the same dimensions along
- the non-leading axes.
- }];
- let arguments = (ins
- HAL_Allocator:$allocator,
- TensorList_TensorList:$list
- );
- let results = (outs
- HAL_BufferView:$tensor
- );
-}
-
-#endif // IREE_DIALECT_MODULES_TENSORLIST_OPS
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.cpp b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.cpp
deleted file mode 100644
index c4951f5..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.cpp
+++ /dev/null
@@ -1,5 +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
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.h b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.h
deleted file mode 100644
index b27f542..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListTypes.h
+++ /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
-
-#ifndef IREE_COMPILER_DIALECT_MODULES_TENSORLIST_IR_TENSORLISTTYPES_H_
-#define IREE_COMPILER_DIALECT_MODULES_TENSORLIST_IR_TENSORLISTTYPES_H_
-
-#include "iree/compiler/Dialect/IREE/IR/IREETypes.h"
-#include "mlir/IR/TypeSupport.h"
-#include "mlir/IR/Types.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace TensorList {
-
-class TensorListType
- : public Type::TypeBase<TensorListType, Type, TypeStorage> {
- public:
- using Base::Base;
-};
-
-} // namespace TensorList
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_DIALECT_MODULES_TENSORLIST_IR_TENSORLISTTYPES_H_
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/test/BUILD b/iree/compiler/Dialect/Modules/TensorList/IR/test/BUILD
deleted file mode 100644
index e7867ec..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/test/BUILD
+++ /dev/null
@@ -1,26 +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("//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(
- ["ops.mlir"],
- include = ["*.mlir"],
- ),
- data = [
- "//iree/tools:IreeFileCheck",
- "//iree/tools:iree-opt",
- ],
-)
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt b/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt
deleted file mode 100644
index f344660..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/test/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/compiler/Dialect/Modules/TensorList/IR/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
- "ops.mlir"
- DATA
- iree::tools::IreeFileCheck
- iree::tools::iree-opt
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/test/ops.mlir b/iree/compiler/Dialect/Modules/TensorList/IR/test/ops.mlir
deleted file mode 100644
index 688bc47..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/IR/test/ops.mlir
+++ /dev/null
@@ -1,44 +0,0 @@
-// RUN: iree-opt -split-input-file %s | iree-opt -split-input-file | IreeFileCheck %s
-
-// CHECK-LABEL: @Reserve
-func @Reserve(%element_shape: !hal.buffer_view, %num_elements: !hal.buffer_view) -> !tensorlist.list {
- // CHECK: tensorlist.Reserve
- %0 = "tensorlist.Reserve"(%element_shape, %num_elements) {element_type = 13 : i32 } : (!hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- return %0 : !tensorlist.list
-}
-
-// -----
-
-// CHECK-LABEL: @GetItem
-func @GetItem(%list: !tensorlist.list, %index: !hal.buffer_view) -> !hal.buffer_view {
- // CHECK: tensorlist.GetItem
- %0 = "tensorlist.GetItem"(%list, %index) : (!tensorlist.list, !hal.buffer_view) -> !hal.buffer_view
- return %0 : !hal.buffer_view
-}
-
-// -----
-
-// CHECK-LABEL: @SetItem
-func @SetItem(%list: !tensorlist.list, %index: !hal.buffer_view, %item: !hal.buffer_view) -> !tensorlist.list {
- // CHECK: tensorlist.SetItem
- %0 = "tensorlist.SetItem"(%list, %index, %item) : (!tensorlist.list, !hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- return %0 : !tensorlist.list
-}
-
-// -----
-
-// CHECK-LABEL: @Stack
-func @Stack(%allocator: !hal.allocator, %list: !tensorlist.list, %num_elements: !hal.buffer_view) -> !hal.buffer_view {
- // CHECK: tensorlist.Stack
- %0 = "tensorlist.Stack"(%allocator, %list, %num_elements) : (!hal.allocator, !tensorlist.list, !hal.buffer_view) -> !hal.buffer_view
- return %0 : !hal.buffer_view
-}
-
-// -----
-
-// CHECK-LABEL: @Concat
-func @Concat(%allocator: !hal.allocator, %list: !tensorlist.list) -> !hal.buffer_view {
- // CHECK: tensorlist.Concat
- %0 = "tensorlist.Concat"(%allocator, %list) : (!hal.allocator, !tensorlist.list) -> !hal.buffer_view
- return %0 : !hal.buffer_view
-}
diff --git a/iree/compiler/Dialect/Modules/TensorList/tensorlist.imports.mlir b/iree/compiler/Dialect/Modules/TensorList/tensorlist.imports.mlir
deleted file mode 100644
index 7d8a1f5..0000000
--- a/iree/compiler/Dialect/Modules/TensorList/tensorlist.imports.mlir
+++ /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
-
-vm.module @tensorlist {
-
-// Maps to IREE::TensorList::Reserve.
-vm.import @reserve(
- %element_shape : !vm.ref<!hal.buffer_view>,
- %num_elements : !vm.ref<!hal.buffer_view>,
- %element_type : i32
-) -> !vm.ref<!tensorlist.list>
-attributes {nosideeffects}
-
-// Maps to IREE::TensorList::GetItem.
-vm.import @get_item(
- %list : !vm.ref<!tensorlist.list>,
- %index : !vm.ref<!hal.buffer_view>
-) -> !vm.ref<!hal.buffer_view>
-attributes {nosideeffects}
-
-// Maps to IREE:TensorList::SetItem
-vm.import @set_item(
- %list : !vm.ref<!tensorlist.list>,
- %index : !vm.ref<!hal.buffer_view>,
- %item : !vm.ref<!hal.buffer_view>
-) -> !vm.ref<!tensorlist.list>
-attributes {nosideeffects}
-
-// Maps to IREE:TensorList::FromTensor
-vm.import @from_tensor(
- %tensor : !vm.ref<!hal.buffer_view>
-) -> !vm.ref<!tensorlist.list>
-attributes {nosideeffects}
-
-// Maps to IREE:TensorList::Concat
-vm.import @concat(
- %allocator : !vm.ref<!hal.allocator>,
- %list : !vm.ref<!tensorlist.list>
-) -> !vm.ref<!hal.buffer_view>
-attributes {nosideeffects}
-
-// Maps to IREE:TensorList::Stack
-vm.import @stack(
- %allocator : !vm.ref<!hal.allocator>,
- %list : !vm.ref<!tensorlist.list>,
- %num_elements : !vm.ref<!hal.buffer_view>
-) -> !vm.ref<!hal.buffer_view>
-attributes {nosideeffects}
-
-} // vm.module
diff --git a/iree/modules/strings/BUILD b/iree/modules/strings/BUILD
deleted file mode 100644
index c6c47e2..0000000
--- a/iree/modules/strings/BUILD
+++ /dev/null
@@ -1,83 +0,0 @@
-load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
-load("//iree/tools:compilation.bzl", "iree_bytecode_module")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-iree_cmake_extra_content(
- content = """
-# absl and benchmark have thread dependency.
-if(NOT ${IREE_ENABLE_THREADING})
- return()
-endif()
-""",
- inline = True,
-)
-
-cc_library(
- name = "strings_module",
- srcs = [
- "api.cc",
- "strings_module.cc",
- ],
- hdrs = [
- "api.h",
- "api_detail.h",
- "strings_module.h",
- ],
- deps = [
- "//iree/base",
- "//iree/base:logging",
- "//iree/base:status",
- "//iree/hal",
- "//iree/modules/hal",
- "//iree/vm",
- "//iree/vm:cc",
- "@com_google_absl//absl/types:span",
- "@com_google_benchmark//:benchmark",
- ],
-)
-
-iree_cmake_extra_content(
- content = """
-if (NOT ${IREE_BUILD_COMPILER})
- return()
-endif()
-""",
- inline = True,
-)
-
-cc_test(
- name = "strings_module_test",
- srcs = ["strings_module_test.cc"],
- deps = [
- ":strings_module",
- ":strings_module_test_module_c",
- "//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",
- "@com_google_absl//absl/types:span",
- "@com_google_benchmark//:benchmark",
- ],
-)
-
-iree_bytecode_module(
- name = "strings_module_test_module",
- testonly = True,
- src = "strings_module_test.mlir",
- c_identifier = "iree_strings_module_test_module",
- flags = [
- "-iree-mlir-to-vm-bytecode-module",
- "-iree-hal-target-backends=dylib-llvm-aot",
- ],
-)
diff --git a/iree/modules/strings/CMakeLists.txt b/iree/modules/strings/CMakeLists.txt
deleted file mode 100644
index b9c2324..0000000
--- a/iree/modules/strings/CMakeLists.txt
+++ /dev/null
@@ -1,81 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/modules/strings/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()
-
-# absl and benchmark have thread dependency.
-if(NOT ${IREE_ENABLE_THREADING})
- return()
-endif()
-
-iree_cc_library(
- NAME
- strings_module
- HDRS
- "api.h"
- "api_detail.h"
- "strings_module.h"
- SRCS
- "api.cc"
- "strings_module.cc"
- DEPS
- absl::span
- benchmark
- iree::base
- iree::base::logging
- iree::base::status
- iree::hal
- iree::modules::hal
- iree::vm
- iree::vm::cc
- PUBLIC
-)
-
-if (NOT ${IREE_BUILD_COMPILER})
- return()
-endif()
-
-iree_cc_test(
- NAME
- strings_module_test
- SRCS
- "strings_module_test.cc"
- DEPS
- ::strings_module
- ::strings_module_test_module_c
- absl::span
- benchmark
- 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
-)
-
-iree_bytecode_module(
- NAME
- strings_module_test_module
- SRC
- "strings_module_test.mlir"
- C_IDENTIFIER
- "iree_strings_module_test_module"
- FLAGS
- "-iree-mlir-to-vm-bytecode-module"
- "-iree-hal-target-backends=dylib-llvm-aot"
- TESTONLY
- PUBLIC
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/modules/strings/api.cc b/iree/modules/strings/api.cc
deleted file mode 100644
index 2a0a9d3..0000000
--- a/iree/modules/strings/api.cc
+++ /dev/null
@@ -1,174 +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
-
-#include "iree/base/api.h"
-
-#include <cstring>
-
-#include "iree/modules/strings/api.h"
-#include "iree/modules/strings/api_detail.h"
-#include "iree/modules/strings/strings_module.h"
-#include "iree/vm/api.h"
-#include "iree/vm/native_module_cc.h"
-
-extern "C" iree_status_t strings_string_create(iree_string_view_t value,
- iree_allocator_t allocator,
- strings_string_t** out_message) {
- // Note that we allocate the message and the string value together.
- strings_string_t* message = NULL;
- IREE_RETURN_IF_ERROR(iree_allocator_malloc(
- allocator, sizeof(strings_string_t) + value.size, (void**)&message));
- message->ref_object.counter = IREE_ATOMIC_VAR_INIT(1);
- message->allocator = allocator;
- message->value.data = ((const char*)message) + sizeof(strings_string_t);
- message->value.size = value.size;
- memcpy((void*)message->value.data, value.data, message->value.size);
- *out_message = message;
- return iree_ok_status();
-}
-
-extern "C" iree_status_t strings_string_tensor_create(
- iree_allocator_t allocator, const iree_string_view_t* value,
- int64_t value_count, const int32_t* shape, size_t rank,
- strings_string_tensor_t** out_message) {
- // TODO(suderman): Use separate allocation for each string. More ref counters
- // but prevents constantly copying.
-
- // Validate the count is correct.
- size_t count = 1;
- for (int i = 0; i < rank; i++) {
- count *= shape[i];
- }
-
- if (count != value_count) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- }
-
- // Compute our total memory requirements
- size_t string_bytes = 0;
- for (int i = 0; i < value_count; i++) {
- string_bytes += value[i].size;
- }
-
- const size_t shape_bytes = rank * sizeof(int32_t);
- const size_t string_view_bytes = value_count * sizeof(iree_string_view_t);
- const size_t byte_count = sizeof(strings_string_tensor_t) + shape_bytes +
- string_view_bytes + string_bytes;
-
- // Allocate and compute byte offsets.
- strings_string_tensor_t* message = NULL;
- IREE_RETURN_IF_ERROR(
- iree_allocator_malloc(allocator, byte_count, (void**)&message));
-
- char* shape_ptr = ((char*)message) + sizeof(strings_string_tensor_t);
- char* string_view_ptr = shape_ptr + shape_bytes;
- char* contents_ptr = string_view_ptr + string_view_bytes;
-
- // Setup the string tensor structure.
- message->shape = (int32_t*)shape_ptr;
- message->values = (iree_string_view_t*)string_view_ptr;
- message->ref_object.counter = IREE_ATOMIC_VAR_INIT(1);
- message->allocator = allocator;
-
- // Set string tensor values.
- message->rank = rank;
- message->count = count;
-
- // Copy the shape.
- memcpy((void*)message->shape, shape, rank * sizeof(int32_t));
-
- // Copy and allocate each string.
- for (int i = 0; i < count; i++) {
- const auto& src = value[i];
- auto& dest = message->values[i];
-
- dest.data = (char*)contents_ptr;
- dest.size = src.size;
- memcpy((void*)dest.data, src.data, src.size);
- contents_ptr += src.size;
- }
-
- *out_message = message;
- return iree_ok_status();
-}
-
-// Returns the count of elements in the tensor.
-iree_status_t strings_string_tensor_get_count(
- const strings_string_tensor_t* tensor, size_t* count) {
- if (!tensor) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- }
- *count = tensor->count;
- return iree_ok_status();
-}
-
-// returns the list of stored string views.
-iree_status_t strings_string_tensor_get_elements(
- const strings_string_tensor_t* tensor, iree_string_view_t* strs,
- size_t count, size_t offset) {
- if (!tensor || offset < 0 || offset + count > tensor->count) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- }
-
- for (size_t i = 0; i < count; i++) {
- strs[i] = tensor->values[i + offset];
- }
- return iree_ok_status();
-}
-
-// Returns the rank of the tensor.
-iree_status_t strings_string_tensor_get_rank(
- const strings_string_tensor_t* tensor, int32_t* rank) {
- if (!tensor || !rank) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- }
- *rank = static_cast<int32_t>(tensor->rank);
- return iree_ok_status();
-}
-
-// Returns the shape of the tensor.
-iree_status_t strings_string_tensor_get_shape(
- const strings_string_tensor_t* tensor, int32_t* shape, size_t rank) {
- if (!tensor || (!shape && rank != 0) || rank != tensor->rank) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- }
-
- for (int i = 0; i < rank; i++) {
- shape[i] = tensor->shape[i];
- }
- return iree_ok_status();
-}
-
-// Returns the store string view using the provided indices.
-iree_status_t strings_string_tensor_get_element(
- const strings_string_tensor_t* tensor, int32_t* indices, size_t rank,
- iree_string_view_t* str) {
- if (!tensor || !indices || rank != tensor->rank) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- }
-
- size_t index = 0;
- for (int i = 0; i < rank; i++) {
- if (indices[i] >= tensor->shape[i]) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- }
-
- index = index * tensor->shape[i] + indices[i];
- }
-
- *str = tensor->values[index];
- return iree_ok_status();
-}
-
-void strings_string_destroy(void* ptr) {
- strings_string_t* message = (strings_string_t*)ptr;
- iree_allocator_free(message->allocator, ptr);
-}
-
-void strings_string_tensor_destroy(void* ptr) {
- strings_string_t* message = (strings_string_t*)ptr;
- iree_allocator_free(message->allocator, ptr);
-}
diff --git a/iree/modules/strings/api.h b/iree/modules/strings/api.h
deleted file mode 100644
index aa9db08..0000000
--- a/iree/modules/strings/api.h
+++ /dev/null
@@ -1,65 +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
-
-#ifndef IREE_MODULES_STRINGS_STRINGS_API_H_
-#define IREE_MODULES_STRINGS_STRINGS_API_H_
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "iree/base/api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-typedef struct strings_string_t strings_string_t;
-typedef struct strings_string_tensor_t strings_string_tensor_t;
-
-// Creates a string type.
-iree_status_t strings_string_create(iree_string_view_t value,
- iree_allocator_t allocator,
- strings_string_t** out_message);
-
-// Creates a string tensor type.
-iree_status_t strings_string_tensor_create(
- iree_allocator_t allocator, const iree_string_view_t* value,
- int64_t value_count, const int32_t* shape, size_t rank,
- strings_string_tensor_t** out_message);
-
-// Destroys a string type.
-void strings_string_destroy(void* ptr);
-
-// Destroys a string tensor
-void strings_string_tensor_destroy(void* ptr);
-
-// Returns the count of elements in the tensor.
-iree_status_t strings_string_tensor_get_count(
- const strings_string_tensor_t* tensor, size_t* count);
-
-// returns the list of stored string views.
-iree_status_t strings_string_tensor_get_elements(
- const strings_string_tensor_t* tensor, iree_string_view_t* strs,
- size_t count, size_t offset);
-
-// Returns the rank of the tensor.
-iree_status_t strings_string_tensor_get_rank(
- const strings_string_tensor_t* tensor, int32_t* rank);
-
-// Returns the shape of the tensor.
-iree_status_t strings_string_tensor_get_shape(
- const strings_string_tensor_t* tensor, int32_t* shape, size_t rank);
-
-// Returns the store string view using the provided indices.
-iree_status_t strings_string_tensor_get_element(
- const strings_string_tensor_t* tensor, int32_t* indices, size_t rank,
- iree_string_view_t* str);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cplusplus
-
-#endif // IREE_MODULES_STRINGS_STRINGS_API_H_
diff --git a/iree/modules/strings/api_detail.h b/iree/modules/strings/api_detail.h
deleted file mode 100644
index 27e351c..0000000
--- a/iree/modules/strings/api_detail.h
+++ /dev/null
@@ -1,39 +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
-
-#ifndef IREE_MODULES_STRINGS_STRINGS_API_DETAIL_H_
-#define IREE_MODULES_STRINGS_STRINGS_API_DETAIL_H_
-
-#include "iree/base/api.h"
-#include "iree/vm/api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-typedef struct strings_string_t {
- iree_vm_ref_object_t ref_object;
- iree_allocator_t allocator;
- iree_string_view_t value;
-} strings_string_t;
-
-typedef struct strings_string_tensor_t {
- iree_vm_ref_object_t ref_object;
- iree_allocator_t allocator;
- iree_string_view_t* values;
- size_t count;
- const int32_t* shape;
- size_t rank;
-} strings_string_tensor_t;
-
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cplusplus
-
-IREE_VM_DECLARE_TYPE_ADAPTERS(strings_string, strings_string_t);
-IREE_VM_DECLARE_TYPE_ADAPTERS(strings_string_tensor, strings_string_tensor_t);
-
-#endif // IREE_MODULES_STRINGS_STRINGS_API_DETAIL_H_
diff --git a/iree/modules/strings/strings_module.cc b/iree/modules/strings/strings_module.cc
deleted file mode 100644
index 064b4a2..0000000
--- a/iree/modules/strings/strings_module.cc
+++ /dev/null
@@ -1,391 +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
-
-#include "iree/modules/strings/strings_module.h"
-
-#include <cstddef>
-#include <cstdint>
-#include <cstdio>
-#include <memory>
-#include <string>
-#include <type_traits>
-#include <vector>
-
-#include "absl/types/span.h"
-#include "iree/base/api.h"
-#include "iree/base/status.h"
-#include "iree/hal/api.h"
-#include "iree/modules/hal/hal_module.h"
-#include "iree/modules/strings/api.h"
-#include "iree/modules/strings/api_detail.h"
-#include "iree/vm/native_module_cc.h"
-#include "iree/vm/ref_cc.h"
-
-static iree_vm_ref_type_descriptor_t strings_string_descriptor = {0};
-static iree_vm_ref_type_descriptor_t strings_string_tensor_descriptor = {0};
-
-IREE_VM_DEFINE_TYPE_ADAPTERS(strings_string, strings_string_t);
-IREE_VM_DEFINE_TYPE_ADAPTERS(strings_string_tensor, strings_string_tensor_t);
-
-namespace iree {
-namespace {
-class StringsModuleState final {
- public:
- explicit StringsModuleState(iree_allocator_t allocator)
- : allocator_(allocator) {}
- ~StringsModuleState() = default;
-
- Status Initialize() { return OkStatus(); }
-
- // strings.print(%str)
- Status Print(vm::ref<strings_string_t> str) {
- fwrite(str->value.data, 1, str->value.size, stdout);
- fputc('\n', stdout);
- fflush(stdout);
- return OkStatus();
- }
-
- // strings.i32_to_string(%value) -> %str
- StatusOr<vm::ref<strings_string_t>> I32ToString(int32_t value) {
- vm::ref<strings_string_t> new_string;
- std::string str = std::to_string(value);
- IREE_RETURN_IF_ERROR(strings_string_create(
- iree_make_cstring_view(str.c_str()), allocator_, &new_string));
- return new_string;
- }
-
- const iree_string_view_t* StringTensorToStringHelper(
- const iree_string_view_t* strs, const int32_t* shape, int32_t rank,
- std::string* output) {
- // Handle a scalar tensor value.
- if (rank == 0) {
- const auto& str = strs[0];
- output->append(str.data, str.size);
- return strs + 1;
- }
-
- // The row for the final tensor dimension.
- if (rank == 1) {
- output->append("[", 1);
- for (int32_t i = 0, s = shape[0]; i < s; i++) {
- const auto& str = strs[i];
- output->append(str.data, str.size);
- if (i != s - 1) {
- output->append(", ", 2);
- }
- }
-
- output->append("]", 1);
- return strs + shape[0];
- }
-
- // Recurse to the lower dimension with the approrpiate brackets.
- output->append("[", 1);
- for (int32_t i = 0, s = shape[0]; i < s; i++) {
- strs = StringTensorToStringHelper(strs, shape + 1, rank - 1, output);
- if (i != s - 1) {
- output->append(",\n", 2);
- }
- }
- output->append("]", 1);
- return strs;
- }
-
- // strings.print_tensor(%str_tensor)
- StatusOr<vm::ref<strings_string_t>> StringTensorToString(
- vm::ref<strings_string_tensor_t> str_tensor) {
- // Perform a rough estimation of the amount of space we need.
- size_t string_length = 0;
- for (int i = 0; i < str_tensor->count; i++) {
- string_length += str_tensor->values[i].size + 2;
- }
-
- vm::ref<strings_string_t> new_string;
- std::string str;
- str.reserve(string_length);
- StringTensorToStringHelper(str_tensor->values, str_tensor->shape,
- static_cast<int32_t>(str_tensor->rank), &str);
-
- IREE_RETURN_IF_ERROR(strings_string_create(
- iree_make_cstring_view(str.c_str()), allocator_, &new_string));
- return new_string;
- }
-
- // strings.to_string_tensor(%hal_buffer) -> %str_tensor
- StatusOr<vm::ref<strings_string_tensor_t>> ToStringTensor(
- vm::ref<iree_hal_buffer_view_t> hal_buffer_view) {
- const size_t rank = iree_hal_buffer_view_shape_rank(hal_buffer_view.get());
- std::vector<iree_hal_dim_t> shape(rank);
- if (rank > 0) {
- IREE_RETURN_IF_ERROR(iree_hal_buffer_view_shape(
- hal_buffer_view.get(), rank, shape.data(), nullptr));
- }
-
- size_t num_elements = 1;
- for (auto val : shape) {
- num_elements *= val;
- }
-
- // Pull the values down.
- size_t element_size =
- iree_hal_buffer_view_element_size(hal_buffer_view.get());
- size_t tensor_size = element_size * num_elements;
- iree_hal_buffer_t* hal_buffer =
- iree_hal_buffer_view_buffer(hal_buffer_view.get());
- iree_hal_buffer_mapping_t tensor_mapping;
- IREE_RETURN_IF_ERROR(iree_hal_buffer_map_range(
- hal_buffer, IREE_HAL_MEMORY_ACCESS_READ,
- /*byte_offset=*/0, tensor_size, &tensor_mapping));
-
- iree_hal_element_type_t type =
- iree_hal_buffer_view_element_type(hal_buffer_view.get());
-
- std::vector<std::string> strings;
- strings.reserve(num_elements);
-
- switch (type) {
- case IREE_HAL_ELEMENT_TYPE_SINT_8:
- GenerateStringsByType<int8_t>(tensor_mapping, strings);
- break;
-
- case IREE_HAL_ELEMENT_TYPE_UINT_8:
- GenerateStringsByType<uint8_t>(tensor_mapping, strings);
- break;
-
- case IREE_HAL_ELEMENT_TYPE_SINT_16:
- GenerateStringsByType<int16_t>(tensor_mapping, strings);
- break;
-
- case IREE_HAL_ELEMENT_TYPE_UINT_16:
- GenerateStringsByType<uint16_t>(tensor_mapping, strings);
- break;
-
- case IREE_HAL_ELEMENT_TYPE_SINT_32:
- GenerateStringsByType<int32_t>(tensor_mapping, strings);
- break;
-
- case IREE_HAL_ELEMENT_TYPE_UINT_32:
- GenerateStringsByType<uint32_t>(tensor_mapping, strings);
- break;
-
- case IREE_HAL_ELEMENT_TYPE_SINT_64:
- GenerateStringsByType<int64_t>(tensor_mapping, strings);
- break;
-
- case IREE_HAL_ELEMENT_TYPE_UINT_64:
- GenerateStringsByType<uint64_t>(tensor_mapping, strings);
- break;
-
- case IREE_HAL_ELEMENT_TYPE_FLOAT_32:
- GenerateStringsByType<float>(tensor_mapping, strings);
- break;
-
- case IREE_HAL_ELEMENT_TYPE_FLOAT_64:
- GenerateStringsByType<double>(tensor_mapping, strings);
- break;
-
- default:
- return iree_make_status(IREE_STATUS_UNIMPLEMENTED);
- }
-
- // Unmap used buffer.
- iree_hal_buffer_unmap_range(&tensor_mapping);
-
- // Place into iree_string_views.
- std::vector<iree_string_view_t> string_views;
- string_views.reserve(num_elements);
-
- for (const auto& str : strings) {
- string_views.push_back(iree_make_cstring_view(str.data()));
- }
-
- strings_string_tensor_t* string_tensor;
- IREE_RETURN_IF_ERROR(strings_string_tensor_create(
- allocator_, string_views.data(), string_views.size(), shape.data(),
- rank, &string_tensor));
-
- return string_tensor;
- }
-
- // strings.gather(%str_tensor, %hal_buffer) -> %str_tensor
- StatusOr<vm::ref<strings_string_tensor_t>> Gather(
- vm::ref<strings_string_tensor_t> dict,
- vm::ref<iree_hal_buffer_view_t> ids) {
- // The dict must be a simple list, and the indices must be integers.
- if (dict->rank != 1 || iree_hal_buffer_view_element_type(ids.get()) !=
- IREE_HAL_ELEMENT_TYPE_SINT_32) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- }
-
- const size_t rank = iree_hal_buffer_view_shape_rank(ids.get());
- std::vector<iree_hal_dim_t> shape(rank);
- if (rank > 0) {
- IREE_RETURN_IF_ERROR(
- iree_hal_buffer_view_shape(ids.get(), rank, shape.data(), nullptr));
- }
-
- size_t num_elements = 1;
- for (auto val : shape) {
- num_elements *= val;
- }
-
- // Pull the values down.
- size_t element_size = iree_hal_buffer_view_element_size(ids.get());
- size_t tensor_size = element_size * num_elements;
- iree_hal_buffer_t* hal_buffer = iree_hal_buffer_view_buffer(ids.get());
- iree_hal_buffer_mapping_t tensor_mapping;
- IREE_RETURN_IF_ERROR(iree_hal_buffer_map_range(
- hal_buffer, IREE_HAL_MEMORY_ACCESS_READ,
- /*byte_offset=*/0, tensor_size, &tensor_mapping));
- iree_string_view_t str;
- const auto& contents = tensor_mapping.contents;
- std::vector<iree_string_view_t> string_views;
- string_views.reserve(num_elements);
-
- for (int32_t *p = (int32_t*)contents.data,
- *s = (int32_t*)(contents.data + contents.data_length);
- p < s; p++) {
- IREE_RETURN_IF_ERROR(
- strings_string_tensor_get_element(dict.get(), p, 1, &str));
- string_views.push_back(str);
- }
-
- // Unmap used buffer.
- iree_hal_buffer_unmap_range(&tensor_mapping);
-
- strings_string_tensor_t* string_tensor;
- IREE_RETURN_IF_ERROR(strings_string_tensor_create(
- allocator_, string_views.data(), string_views.size(), shape.data(),
- rank, &string_tensor));
- return string_tensor;
- }
-
- // strings.concat(%str_tensor) -> %str_tensor
- StatusOr<vm::ref<strings_string_tensor_t>> Concat(
- vm::ref<strings_string_tensor_t> str_tensor) {
- size_t new_rank = str_tensor->rank - 1;
- const int32_t* shape = str_tensor->shape;
- int32_t last_dim = shape[new_rank];
-
- int32_t rank_mul = 1;
- for (int32_t i = 0; i < new_rank; i++) {
- rank_mul *= shape[i];
- }
-
- // Place into iree_string_views.
- std::vector<iree_string_view_t> string_views;
- string_views.reserve(rank_mul);
- std::vector<std::string> strings;
- strings.reserve(rank_mul);
-
- for (int32_t i = 0; i < rank_mul; i++) {
- std::string str;
- for (int32_t j = 0; j < last_dim; j++) {
- int32_t curr_pos = i * last_dim + j;
- iree_string_view_t curr_str = str_tensor->values[curr_pos];
- str.append(curr_str.data, curr_str.size);
- }
- strings.push_back(str);
- }
-
- for (int i = 0; i < strings.size(); i++) {
- string_views.push_back(iree_make_cstring_view(strings[i].data()));
- }
-
- strings_string_tensor_t* string_tensor;
- IREE_RETURN_IF_ERROR(strings_string_tensor_create(
- allocator_, string_views.data(), string_views.size(), shape, new_rank,
- &string_tensor));
- return string_tensor;
- }
-
- private:
- // Allocator that the caller requested we use for any allocations we need to
- // perform during operation.
- iree_allocator_t allocator_ = iree_allocator_system();
-
- template <typename T>
- void GenerateStringsByType(iree_hal_buffer_mapping_t tensor_mapping,
- std::vector<std::string>& strings) {
- const auto& contents = tensor_mapping.contents;
- for (const T *p = (const T*)contents.data,
- *s = (const T*)(contents.data + contents.data_length);
- p < s; p++) {
- std::string str = std::to_string(*p);
- strings.push_back(std::move(str));
- }
- }
-};
-
-static const vm::NativeFunction<StringsModuleState> kStringsModuleFunctions[] =
- {
- vm::MakeNativeFunction("print", &StringsModuleState::Print),
- vm::MakeNativeFunction("i32_to_string",
- &StringsModuleState::I32ToString),
- vm::MakeNativeFunction("string_tensor_to_string",
- &StringsModuleState::StringTensorToString),
- vm::MakeNativeFunction("to_string_tensor",
- &StringsModuleState::ToStringTensor),
- vm::MakeNativeFunction("gather", &StringsModuleState::Gather),
- vm::MakeNativeFunction("concat", &StringsModuleState::Concat),
-};
-
-class StringsModule final : public vm::NativeModule<StringsModuleState> {
- public:
- using vm::NativeModule<StringsModuleState>::NativeModule;
-
- // Example of global initialization (shared across all contexts), such as
- // loading native libraries or creating shared pools.
- Status Initialize() { 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<StringsModuleState>> CreateState(
- iree_allocator_t allocator) override {
- auto state = std::make_unique<StringsModuleState>(allocator);
- IREE_RETURN_IF_ERROR(state->Initialize());
- return state;
- }
-};
-
-} // namespace
-} // namespace iree
-
-extern "C" iree_status_t iree_strings_module_register_types(void) {
- if (strings_string_descriptor.type) {
- return iree_ok_status(); // Already registered.
- }
-
- // Register strings.string
- strings_string_descriptor.type_name =
- iree_make_cstring_view("strings.string");
- strings_string_descriptor.offsetof_counter =
- offsetof(strings_string_t, ref_object.counter);
- strings_string_descriptor.destroy = strings_string_destroy;
- IREE_RETURN_IF_ERROR(iree_vm_ref_register_type(&strings_string_descriptor));
-
- // Register strings.string_tensor
- strings_string_tensor_descriptor.type_name =
- iree_make_cstring_view("strings.string_tensor");
- strings_string_tensor_descriptor.offsetof_counter =
- offsetof(strings_string_tensor_t, ref_object.counter);
- strings_string_tensor_descriptor.destroy = strings_string_tensor_destroy;
- IREE_RETURN_IF_ERROR(
- iree_vm_ref_register_type(&strings_string_tensor_descriptor));
-
- return iree_ok_status();
-}
-
-extern "C" iree_status_t iree_strings_module_create(
- iree_allocator_t allocator, iree_vm_module_t** out_module) {
- if (!out_module) return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- *out_module = NULL;
- auto module = std::make_unique<iree::StringsModule>(
- "strings", allocator, absl::MakeConstSpan(iree::kStringsModuleFunctions));
- IREE_RETURN_IF_ERROR(module->Initialize());
- *out_module = module.release()->interface();
- return iree_ok_status();
-}
diff --git a/iree/modules/strings/strings_module.h b/iree/modules/strings/strings_module.h
deleted file mode 100644
index f2779e5..0000000
--- a/iree/modules/strings/strings_module.h
+++ /dev/null
@@ -1,31 +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
-
-#ifndef IREE_MODULES_STRINGS_STRINGS_MODULE_H_
-#define IREE_MODULES_STRINGS_STRINGS_MODULE_H_
-
-#include "iree/base/api.h"
-#include "iree/vm/api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-// Registers the custom types used by the strings module.
-// WARNING: Not threadsafe; call at startup before using..
-iree_status_t iree_strings_module_register_types(void);
-
-// Creates a strings module.
-// Modules may exist in multiple contexts should be thread-safe and immutable.
-// Use the per-context allocated state for retaining data.
-iree_status_t iree_strings_module_create(iree_allocator_t allocator,
- iree_vm_module_t** out_module);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cplusplus
-
-#endif // IREE_MODULES_STRINGS_STRINGS_MODULE_H_
diff --git a/iree/modules/strings/strings_module_test.cc b/iree/modules/strings/strings_module_test.cc
deleted file mode 100644
index e6dbcbb..0000000
--- a/iree/modules/strings/strings_module_test.cc
+++ /dev/null
@@ -1,588 +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
-
-#include "iree/modules/strings/strings_module.h"
-
-#include <cstdint>
-#include <vector>
-
-#include "absl/types/span.h"
-#include "iree/base/api.h"
-#include "iree/base/logging.h"
-#include "iree/hal/api.h"
-#include "iree/hal/vmvx/registration/driver_module.h"
-#include "iree/modules/hal/hal_module.h"
-#include "iree/modules/strings/api.h"
-#include "iree/modules/strings/api_detail.h"
-#include "iree/modules/strings/strings_module_test_module_c.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"
-
-using testing::internal::CaptureStdout;
-using testing::internal::GetCapturedStdout;
-
-namespace iree {
-
-namespace {
-
-class StringsModuleTest : 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_));
-
- // Setup strings module:
- IREE_CHECK_OK(iree_strings_module_register_types());
- IREE_CHECK_OK(
- iree_strings_module_create(iree_allocator_system(), &strings_module_));
-
- // Setup hal module:
- IREE_CHECK_OK(iree_hal_module_register_types());
- 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_CHECK_OK(iree_hal_driver_create_default_device(
- hal_driver, iree_allocator_system(), &device_));
- IREE_CHECK_OK(
- iree_hal_module_create(device_, iree_allocator_system(), &hal_module_));
- iree_hal_driver_release(hal_driver);
-
- // Setup the test module.
- const auto* module_file_toc = iree_strings_module_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 = {strings_module_, hal_module_,
- bytecode_module_};
- IREE_CHECK_OK(iree_vm_context_create_with_modules(
- instance_, modules.data(), modules.size(), iree_allocator_system(),
- &context_));
- }
-
- virtual void TearDown() {
- iree_hal_device_release(device_);
- iree_vm_module_release(strings_module_);
- iree_vm_module_release(bytecode_module_);
- iree_vm_module_release(hal_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;
- }
-
- template <typename T, iree_hal_element_type_t E>
- void CreateBufferView(absl::Span<const T> contents,
- absl::Span<const int32_t> shape,
- iree_hal_buffer_view_t** out_buffer_view) {
- size_t num_elements = 1;
- for (int32_t dim : shape) {
- num_elements *= dim;
- }
- ASSERT_EQ(contents.size(), num_elements);
- vm::ref<iree_hal_buffer_t> buffer;
- iree_hal_allocator_t* allocator = iree_hal_device_allocator(device_);
- IREE_ASSERT_OK(iree_hal_allocator_allocate_buffer(
- allocator,
- static_cast<iree_hal_memory_type_t>(
- IREE_HAL_MEMORY_TYPE_HOST_LOCAL |
- IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE),
- IREE_HAL_BUFFER_USAGE_ALL, contents.size() * sizeof(T), &buffer));
- IREE_ASSERT_OK(iree_hal_buffer_write_data(buffer.get(), 0, contents.data(),
- contents.size() * sizeof(T)));
- IREE_ASSERT_OK(iree_hal_buffer_view_create(
- buffer.get(), shape.data(), shape.size(), E, &*out_buffer_view));
- }
-
- void TestStringTensorToString(
- absl::Span<const iree_string_view_t> string_views,
- absl::Span<const int32_t> shape, const std::string& expected_output) {
- vm::ref<strings_string_tensor_t> input_string_tensor;
- IREE_ASSERT_OK(strings_string_tensor_create(
- iree_allocator_system(), string_views.data(), string_views.size(),
- shape.data(), shape.size(), &input_string_tensor));
-
- // Construct the input list for execution.
- vm::ref<iree_vm_list_t> inputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &inputs));
-
- // Add the string tensor to the input list.
- IREE_ASSERT_OK(
- iree_vm_list_push_ref_retain(inputs.get(), input_string_tensor));
-
- // Construct the output list for accepting results from the invocation.
- vm::ref<iree_vm_list_t> outputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &outputs));
-
- // Invoke the function.
- IREE_ASSERT_OK(iree_vm_invoke(context_,
- LookupFunction("string_tensor_to_string"),
- /*policy=*/nullptr, inputs.get(),
- outputs.get(), iree_allocator_system()));
-
- // Retrieve and validate the string tensor.
- auto* output_string =
- reinterpret_cast<strings_string_t*>(iree_vm_list_get_ref_deref(
- outputs.get(), 0, strings_string_get_descriptor()));
- ASSERT_EQ(output_string->value.size, expected_output.size());
- EXPECT_EQ(std::string(output_string->value.data, output_string->value.size),
- expected_output);
- }
-
- template <typename T, iree_hal_element_type_t E>
- void TestToStringTensor(absl::Span<const T> contents,
- absl::Span<const int32_t> shape,
- absl::Span<const iree_string_view_t> expected) {
- vm::ref<iree_hal_buffer_view_t> input_buffer_view;
- CreateBufferView<T, E>(contents, shape, &input_buffer_view);
-
- // Construct the input list for execution.
- vm::ref<iree_vm_list_t> inputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &inputs));
-
- // Add the buffer view to the input list.
- IREE_ASSERT_OK(
- iree_vm_list_push_ref_retain(inputs.get(), input_buffer_view));
-
- // Construct the output list for accepting results from the invocation.
- vm::ref<iree_vm_list_t> outputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &outputs));
-
- // Invoke the function.
- IREE_ASSERT_OK(iree_vm_invoke(context_, LookupFunction("to_string_tensor"),
- /*policy=*/nullptr, inputs.get(),
- outputs.get(), iree_allocator_system()));
-
- // Compare the output to the expected result.
- CompareResults(expected, shape, outputs);
- }
-
- void TestGather(absl::Span<const iree_string_view_t> dict,
- absl::Span<const int32_t> dict_shape,
- absl::Span<const int32_t> ids,
- absl::Span<const int32_t> ids_shape,
- absl::Span<const iree_string_view_t> expected) {
- vm::ref<strings_string_tensor_t> dict_string_tensor;
- IREE_ASSERT_OK(strings_string_tensor_create(
- iree_allocator_system(), dict.data(), dict.size(), dict_shape.data(),
- dict_shape.size(), &dict_string_tensor));
-
- // Construct the input list for execution.
- vm::ref<iree_vm_list_t> inputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 2,
- iree_allocator_system(), &inputs));
-
- // Add the dict to the input list.
- iree_vm_ref_t dict_string_tensor_ref =
- strings_string_tensor_move_ref(dict_string_tensor.get());
- IREE_ASSERT_OK(
- iree_vm_list_push_ref_retain(inputs.get(), &dict_string_tensor_ref));
-
- vm::ref<iree_hal_buffer_view_t> input_buffer_view;
- CreateBufferView<int32_t, IREE_HAL_ELEMENT_TYPE_SINT_32>(
- ids, ids_shape, &input_buffer_view);
-
- // Add the ids tensor to the input list.
- IREE_ASSERT_OK(
- iree_vm_list_push_ref_retain(inputs.get(), input_buffer_view));
-
- // Construct the output list for accepting results from the invocation.
- vm::ref<iree_vm_list_t> outputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &outputs));
-
- // Invoke the function.
- IREE_ASSERT_OK(iree_vm_invoke(context_, LookupFunction("gather"),
- /*policy=*/nullptr, inputs.get(),
- outputs.get(), iree_allocator_system()));
-
- // Compare the output to the expected result.
- CompareResults(expected, ids_shape, std::move(outputs));
- }
-
- void TestConcat(absl::Span<const iree_string_view_t> string_views,
- absl::Span<const int32_t> shape,
- absl::Span<const iree_string_view_t> expected) {
- vm::ref<strings_string_tensor_t> string_tensor;
- IREE_ASSERT_OK(strings_string_tensor_create(
- iree_allocator_system(), string_views.data(), string_views.size(),
- shape.data(), shape.size(), &string_tensor));
-
- // Construct the input list for execution.
- vm::ref<iree_vm_list_t> inputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &inputs));
-
- // Add the dict to the input list.
- IREE_ASSERT_OK(iree_vm_list_push_ref_retain(inputs.get(), string_tensor));
-
- // Construct the output list for accepting results from the invocation.
- vm::ref<iree_vm_list_t> outputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &outputs));
-
- // Invoke the function.
- IREE_ASSERT_OK(iree_vm_invoke(context_, LookupFunction("concat"),
- /*policy=*/nullptr, inputs.get(),
- outputs.get(), iree_allocator_system()));
-
- // Remove the last dimension from the shape to get the expected shape
- shape.remove_suffix(1);
-
- // Compare the output to the expected result.
- CompareResults(expected, shape, std::move(outputs));
- }
-
- void CompareResults(absl::Span<const iree_string_view_t> expected,
- absl::Span<const int32_t> expected_shape,
- vm::ref<iree_vm_list_t> outputs) {
- // Retrieve and validate the string tensor.
- auto* output_tensor =
- reinterpret_cast<strings_string_tensor_t*>(iree_vm_list_get_ref_deref(
- outputs.get(), 0, strings_string_tensor_get_descriptor()));
-
- // Validate the count.
- size_t count;
- IREE_ASSERT_OK(strings_string_tensor_get_count(output_tensor, &count));
- EXPECT_EQ(count, expected.size());
-
- // Validate the rank.
- int32_t rank;
- IREE_ASSERT_OK(strings_string_tensor_get_rank(output_tensor, &rank));
- ASSERT_EQ(rank, expected_shape.size());
-
- // Validate the shape.
- std::vector<int32_t> out_shape(rank);
- IREE_ASSERT_OK(
- strings_string_tensor_get_shape(output_tensor, out_shape.data(), rank));
- for (int i = 0; i < rank; i++) {
- EXPECT_EQ(out_shape[i], expected_shape[i])
- << "Dimension : " << i << " does not match";
- }
-
- // Fetch and validate string contents.
- std::vector<iree_string_view_t> out_strings(expected.size());
- IREE_ASSERT_OK(strings_string_tensor_get_elements(
- output_tensor, out_strings.data(), out_strings.size(), 0));
- for (iree_host_size_t i = 0; i < expected.size(); i++) {
- EXPECT_EQ(iree_string_view_compare(out_strings[i], expected[i]), 0)
- << "Expected: " << expected[i].data << " found "
- << out_strings[i].data;
- }
- }
-
- iree_hal_device_t* device_ = nullptr;
- iree_vm_instance_t* instance_ = nullptr;
- iree_vm_context_t* context_ = nullptr;
- iree_vm_module_t* bytecode_module_ = nullptr;
- iree_vm_module_t* strings_module_ = nullptr;
- iree_vm_module_t* hal_module_ = nullptr;
-};
-
-TEST_F(StringsModuleTest, Prototype) {
- const int input = 42;
- std::string expected_output = "42\n";
-
- // Construct the input list for execution.
- vm::ref<iree_vm_list_t> inputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &inputs));
-
- // Add the value parameter.
- iree_vm_value_t value = iree_vm_value_make_i32(input);
- IREE_ASSERT_OK(iree_vm_list_push_value(inputs.get(), &value));
-
- // Prepare outputs list to accept the results from the invocation.
- vm::ref<iree_vm_list_t> outputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 0,
- iree_allocator_system(), &outputs));
-
- CaptureStdout();
- IREE_ASSERT_OK(iree_vm_invoke(context_, LookupFunction("print_example_func"),
- /*policy=*/nullptr, inputs.get(), outputs.get(),
- iree_allocator_system()));
- EXPECT_EQ(GetCapturedStdout(), expected_output);
-}
-
-TEST_F(StringsModuleTest, StringTensorToString_Scalar) {
- // Expected output.
- std::string expected_output = "str";
- std::vector<iree_string_view_t> string_views = {
- iree_make_cstring_view("str")};
- TestStringTensorToString(string_views, {}, expected_output);
-}
-
-TEST_F(StringsModuleTest, StringTensorToString_Vector) {
- // Expected output.
- std::string expected_output = "[str1, str2]";
- std::vector<iree_string_view_t> string_views = {
- iree_make_cstring_view("str1"),
- iree_make_cstring_view("str2"),
- };
- TestStringTensorToString(string_views, {2}, expected_output);
-}
-
-TEST_F(StringsModuleTest, StringTensorToString_Tensor) {
- // Expected output.
- std::string expected_output = "[[[str1, str2]],\n[[str3, str4]]]";
- std::vector<iree_string_view_t> string_views = {
- iree_make_cstring_view("str1"), iree_make_cstring_view("str2"),
- iree_make_cstring_view("str3"), iree_make_cstring_view("str4")};
- std::vector<int32_t> shape = {2, 1, 2};
- TestStringTensorToString(string_views, shape, expected_output);
-}
-
-TEST_F(StringsModuleTest, ToString_Scalar) {
- std::vector<iree_string_view_t> expected{iree_make_cstring_view("14.000000")};
- std::vector<float> contents{14.0f};
- TestToStringTensor<float, IREE_HAL_ELEMENT_TYPE_FLOAT_32>(contents, {},
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Vector) {
- std::vector<iree_string_view_t> expected{iree_make_cstring_view("42.000000"),
- iree_make_cstring_view("43.000000")};
-
- std::vector<float> contents{42.0f, 43.0f};
- std::vector<int32_t> shape{2};
- TestToStringTensor<float, IREE_HAL_ELEMENT_TYPE_FLOAT_32>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Tensor) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("1.000000"), iree_make_cstring_view("2.000000"),
- iree_make_cstring_view("3.000000"), iree_make_cstring_view("4.000000")};
-
- std::vector<float> contents{1.0f, 2.0f, 3.0f, 4.0f};
- std::vector<int32_t> shape{1, 2, 1, 1, 2};
- TestToStringTensor<float, IREE_HAL_ELEMENT_TYPE_FLOAT_32>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Tensor_Signed_Int8) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("-1"), iree_make_cstring_view("2"),
- iree_make_cstring_view("3"), iree_make_cstring_view("127")};
-
- std::vector<int8_t> contents{-1, 2, 3, 127};
- std::vector<int32_t> shape{1, 2, 1, 1, 2};
- TestToStringTensor<int8_t, IREE_HAL_ELEMENT_TYPE_SINT_8>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Tensor_Unsigned_Int8) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("1"), iree_make_cstring_view("2"),
- iree_make_cstring_view("3"), iree_make_cstring_view("255")};
-
- std::vector<uint8_t> contents{1, 2, 3, 255};
- std::vector<int32_t> shape{1, 2, 1, 1, 2};
- TestToStringTensor<uint8_t, IREE_HAL_ELEMENT_TYPE_UINT_8>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Tensor_Signed_Int16) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("-1"), iree_make_cstring_view("2"),
- iree_make_cstring_view("3"), iree_make_cstring_view("32700")};
-
- std::vector<int16_t> contents{-1, 2, 3, 32700};
- std::vector<int32_t> shape{1, 2, 1, 1, 2};
- TestToStringTensor<int16_t, IREE_HAL_ELEMENT_TYPE_SINT_16>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Tensor_Unsigned_Int16) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("1"), iree_make_cstring_view("2"),
- iree_make_cstring_view("3"), iree_make_cstring_view("65000")};
-
- std::vector<uint16_t> contents{1, 2, 3, 65000};
- std::vector<int32_t> shape{1, 2, 1, 1, 2};
- TestToStringTensor<uint16_t, IREE_HAL_ELEMENT_TYPE_UINT_16>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Tensor_Signed_Int32) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("-1"), iree_make_cstring_view("2"),
- iree_make_cstring_view("3"), iree_make_cstring_view("2140000000")};
-
- std::vector<int32_t> contents{-1, 2, 3, 2140000000};
- std::vector<int32_t> shape{1, 2, 1, 1, 2};
- TestToStringTensor<int32_t, IREE_HAL_ELEMENT_TYPE_SINT_32>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Tensor_Unsigned_Int32) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("1"), iree_make_cstring_view("2"),
- iree_make_cstring_view("3"), iree_make_cstring_view("4290000000")};
-
- std::vector<uint32_t> contents{1, 2, 3, 4290000000};
- std::vector<int32_t> shape{1, 2, 1, 1, 2};
- TestToStringTensor<uint32_t, IREE_HAL_ELEMENT_TYPE_UINT_32>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Tensor_Signed_Int64) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("-1"), iree_make_cstring_view("2"),
- iree_make_cstring_view("3"), iree_make_cstring_view("4300000000")};
-
- std::vector<int64_t> contents{-1, 2, 3, 4300000000};
- std::vector<int32_t> shape{1, 2, 1, 1, 2};
- TestToStringTensor<int64_t, IREE_HAL_ELEMENT_TYPE_SINT_64>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Tensor_Unsigned_Int64) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("1"), iree_make_cstring_view("2"),
- iree_make_cstring_view("3"), iree_make_cstring_view("4300000000")};
-
- std::vector<uint64_t> contents{1, 2, 3, 4300000000};
- std::vector<int32_t> shape{1, 2, 1, 1, 2};
- TestToStringTensor<uint64_t, IREE_HAL_ELEMENT_TYPE_UINT_64>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, ToString_Vector_Float_64) {
- std::vector<iree_string_view_t> expected{iree_make_cstring_view("42.000000"),
- iree_make_cstring_view("43.000000")};
-
- std::vector<double> contents{42.0f, 43.0f};
- std::vector<int32_t> shape{2};
- TestToStringTensor<double, IREE_HAL_ELEMENT_TYPE_FLOAT_64>(contents, shape,
- expected);
-}
-
-TEST_F(StringsModuleTest, GatherSingleElement) {
- std::vector<iree_string_view_t> expected{iree_make_cstring_view("World")};
-
- std::vector<iree_string_view_t> dict{iree_make_cstring_view("Hello"),
- iree_make_cstring_view("World"),
- iree_make_cstring_view("!")};
- std::vector<int32_t> dict_shape{3};
-
- std::vector<int32_t> ids{1};
- std::vector<int32_t> ids_shape{1};
-
- TestGather(dict, dict_shape, ids, ids_shape, expected);
-}
-
-TEST_F(StringsModuleTest, GatherMultipleElements) {
- std::vector<iree_string_view_t> expected{iree_make_cstring_view("World"),
- iree_make_cstring_view("Hello")};
-
- std::vector<iree_string_view_t> dict{iree_make_cstring_view("Hello"),
- iree_make_cstring_view("World"),
- iree_make_cstring_view("!")};
- std::vector<int32_t> dict_shape{3};
-
- std::vector<int32_t> ids{1, 0};
- std::vector<int32_t> ids_shape{2};
-
- TestGather(dict, dict_shape, ids, ids_shape, expected);
-}
-
-TEST_F(StringsModuleTest, GatherHigherRank) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("!"), iree_make_cstring_view("!"),
- iree_make_cstring_view("Hello"), iree_make_cstring_view("World"),
- iree_make_cstring_view("!"), iree_make_cstring_view("!")};
-
- std::vector<iree_string_view_t> dict{iree_make_cstring_view("Hello"),
- iree_make_cstring_view("World"),
- iree_make_cstring_view("!")};
- std::vector<int32_t> dict_shape{3};
-
- std::vector<int32_t> ids{2, 2, 0, 1, 2, 2};
- std::vector<int32_t> ids_shape{2, 3, 1, 1};
-
- TestGather(dict, dict_shape, ids, ids_shape, expected);
-}
-
-TEST_F(StringsModuleTest, Concat) {
- std::vector<iree_string_view_t> expected{iree_make_cstring_view("abc"),
- iree_make_cstring_view("def")};
-
- std::vector<iree_string_view_t> contents{
- iree_make_cstring_view("a"), iree_make_cstring_view("b"),
- iree_make_cstring_view("c"), iree_make_cstring_view("d"),
- iree_make_cstring_view("e"), iree_make_cstring_view("f")};
- std::vector<int32_t> shape{2, 3};
-
- TestConcat(contents, shape, expected);
-}
-
-TEST_F(StringsModuleTest, ConcatMultiDim) {
- std::vector<iree_string_view_t> expected{
- iree_make_cstring_view("abc"), iree_make_cstring_view("def"),
- iree_make_cstring_view("ghi"), iree_make_cstring_view("jkl")};
-
- std::vector<iree_string_view_t> contents{
- iree_make_cstring_view("a"), iree_make_cstring_view("b"),
- iree_make_cstring_view("c"), iree_make_cstring_view("d"),
- iree_make_cstring_view("e"), iree_make_cstring_view("f"),
- iree_make_cstring_view("g"), iree_make_cstring_view("h"),
- iree_make_cstring_view("i"), iree_make_cstring_view("j"),
- iree_make_cstring_view("k"), iree_make_cstring_view("l")};
- std::vector<int32_t> shape{2, 2, 3};
-
- TestConcat(contents, shape, expected);
-}
-
-TEST_F(StringsModuleTest, IdsToStrings) {
- std::vector<iree_string_view_t> intermediate_expected{
- iree_make_cstring_view("Hello"), iree_make_cstring_view("World"),
- iree_make_cstring_view("World"), iree_make_cstring_view("World"),
- iree_make_cstring_view("Hello"), iree_make_cstring_view("World"),
- iree_make_cstring_view("Hello"), iree_make_cstring_view("World"),
- iree_make_cstring_view("!"), iree_make_cstring_view("!"),
- iree_make_cstring_view("World"), iree_make_cstring_view("!")};
-
- std::vector<iree_string_view_t> dict{iree_make_cstring_view("Hello"),
- iree_make_cstring_view("World"),
- iree_make_cstring_view("!")};
- std::vector<int32_t> dict_shape{3};
-
- std::vector<int32_t> ids{0, 1, 1, 1, 0, 1, 0, 1, 2, 2, 1, 2};
- std::vector<int32_t> ids_shape{1, 1, 4, 3};
-
- TestGather(dict, dict_shape, ids, ids_shape, intermediate_expected);
-
- std::vector<iree_string_view_t> final_expected{
- iree_make_cstring_view("HelloWorldWorld"),
- iree_make_cstring_view("WorldHelloWorld"),
- iree_make_cstring_view("HelloWorld!"), iree_make_cstring_view("!World!")};
-
- TestConcat(intermediate_expected, ids_shape, final_expected);
-}
-
-} // namespace
-} // namespace iree
diff --git a/iree/modules/strings/strings_module_test.mlir b/iree/modules/strings/strings_module_test.mlir
deleted file mode 100644
index 8d1b049..0000000
--- a/iree/modules/strings/strings_module_test.mlir
+++ /dev/null
@@ -1,31 +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
-
-func @print_example_func(%arg0 : i32) {
- %0 = "strings.i32_to_string"(%arg0) : (i32) -> !strings.string
- "strings.print"(%0) : (!strings.string) -> ()
- return
-}
-
-func @string_tensor_to_string(%arg0 : !strings.string_tensor) -> !strings.string attributes { iree.module.export, iree.abi.none } {
- %0 = "strings.string_tensor_to_string"(%arg0) : (!strings.string_tensor) -> (!strings.string)
- return %0 : !strings.string
-}
-
-func @to_string_tensor(%arg0 : !hal.buffer_view) -> !strings.string_tensor attributes { iree.module.export, iree.abi.none } {
- %0 = "strings.to_string_tensor"(%arg0) : (!hal.buffer_view) -> !strings.string_tensor
- return %0 : !strings.string_tensor
-}
-
-func @gather(%arg0 : !strings.string_tensor, %arg1 : !hal.buffer_view) -> !strings.string_tensor attributes { iree.module.export, iree.abi.none } {
- %0 = "strings.gather"(%arg0, %arg1) : (!strings.string_tensor, !hal.buffer_view) -> !strings.string_tensor
- return %0 : !strings.string_tensor
-}
-
-func @concat(%arg0 : !strings.string_tensor) -> !strings.string_tensor attributes { iree.module.export, iree.abi.none } {
- %0 = "strings.concat"(%arg0) : (!strings.string_tensor) -> !strings.string_tensor
- return %0 : !strings.string_tensor
-}
diff --git a/iree/modules/tensorlist/BUILD b/iree/modules/tensorlist/BUILD
deleted file mode 100644
index 730911e..0000000
--- a/iree/modules/tensorlist/BUILD
+++ /dev/null
@@ -1,80 +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
-
-load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
-load("//iree/tools:compilation.bzl", "iree_bytecode_module")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-iree_cmake_extra_content(
- content = """
-# absl has thread dependency.
-# TODO(#3848): Remove this condition.
-if(NOT ${IREE_ENABLE_THREADING})
- return()
-endif()
-""",
- inline = True,
-)
-
-cc_library(
- name = "native_module",
- srcs = ["native_module.cc"],
- hdrs = ["native_module.h"],
- deps = [
- "//iree/base",
- "//iree/base:status",
- "//iree/hal",
- "//iree/modules/hal",
- "//iree/vm",
- "//iree/vm:cc",
- "@com_google_absl//absl/types:span",
- ],
-)
-
-iree_cmake_extra_content(
- content = """
-if (NOT ${IREE_BUILD_COMPILER})
- return()
-endif()
-""",
- inline = True,
-)
-
-iree_bytecode_module(
- name = "tensorlist_test_module",
- testonly = True,
- src = "tensorlist_test.mlir",
- c_identifier = "iree_tensorlist_test_module",
- flags = [
- "-iree-mlir-to-vm-bytecode-module",
- "-iree-hal-target-backends=dylib-llvm-aot",
- ],
-)
-
-cc_test(
- name = "tensorlist_test",
- srcs = ["tensorlist_test.cc"],
- deps = [
- ":native_module",
- ":tensorlist_test_module_c",
- "//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",
- "@com_google_absl//absl/types:span",
- ],
-)
diff --git a/iree/modules/tensorlist/CMakeLists.txt b/iree/modules/tensorlist/CMakeLists.txt
deleted file mode 100644
index 5438c73..0000000
--- a/iree/modules/tensorlist/CMakeLists.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# iree/modules/tensorlist/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()
-
-# absl has thread dependency.
-# TODO(#3848): Remove this condition.
-if(NOT ${IREE_ENABLE_THREADING})
- return()
-endif()
-
-iree_cc_library(
- NAME
- native_module
- HDRS
- "native_module.h"
- SRCS
- "native_module.cc"
- DEPS
- absl::span
- iree::base
- iree::base::status
- iree::hal
- iree::modules::hal
- iree::vm
- iree::vm::cc
- PUBLIC
-)
-
-if (NOT ${IREE_BUILD_COMPILER})
- return()
-endif()
-
-iree_bytecode_module(
- NAME
- tensorlist_test_module
- SRC
- "tensorlist_test.mlir"
- C_IDENTIFIER
- "iree_tensorlist_test_module"
- FLAGS
- "-iree-mlir-to-vm-bytecode-module"
- "-iree-hal-target-backends=dylib-llvm-aot"
- TESTONLY
- PUBLIC
-)
-
-iree_cc_test(
- NAME
- tensorlist_test
- SRCS
- "tensorlist_test.cc"
- DEPS
- ::native_module
- ::tensorlist_test_module_c
- absl::span
- 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/iree/modules/tensorlist/README.md b/iree/modules/tensorlist/README.md
deleted file mode 100644
index 5993f3b..0000000
--- a/iree/modules/tensorlist/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Corresponding compiler parts in `iree/compiler/Dialect/Modules/TensorList`.
diff --git a/iree/modules/tensorlist/native_module.cc b/iree/modules/tensorlist/native_module.cc
deleted file mode 100644
index 198e362..0000000
--- a/iree/modules/tensorlist/native_module.cc
+++ /dev/null
@@ -1,485 +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
-
-#include "iree/modules/tensorlist/native_module.h"
-
-#include <cstdint>
-#include <cstdio>
-#include <cstring>
-#include <memory>
-#include <type_traits>
-#include <vector>
-
-#include "absl/types/span.h"
-#include "iree/base/api.h"
-#include "iree/base/status.h"
-#include "iree/hal/api.h"
-#include "iree/modules/hal/hal_module.h"
-#include "iree/vm/native_module_cc.h"
-#include "iree/vm/ref_cc.h"
-
-namespace iree {
-
-//===----------------------------------------------------------------------===//
-// TensorList runtime type.
-// This is the type that backs the `tensorlist.list` VM type.
-//===----------------------------------------------------------------------===//
-
-namespace {
-class TensorList final : public iree::vm::RefObject<TensorList> {
- public:
- TensorList(absl::Span<const int32_t> shape, iree_hal_element_type_t dtype)
- : shape_(shape.begin(), shape.end()), dtype_(dtype) {}
-
- TensorList(const vm::ref<TensorList>& other)
- : shape_(other->shape_), dtype_(other->dtype_) {
- CopyFrom(other);
- }
-
- void Resize(int32_t num_elements) { list_.resize(num_elements); }
- // Copy from another iree_tensorlist.
- // vm::ref has deleted copy operator=, so we can't use vector's operator=.
- void CopyFrom(const vm::ref<TensorList>& other) {
- list_.clear();
- for (auto& element : other->list_) {
- list_.push_back(vm::retain_ref(element));
- }
- }
- const vm::ref<iree_hal_buffer_view_t>& GetItem(int32_t index) const {
- // TODO(silvasean): Correct out-of-bounds behavior.
- return list_.at(index);
- }
- void SetItem(int32_t index, vm::ref<iree_hal_buffer_view_t> item) {
- // TODO(silvasean): Correct out-of-bounds behavior.
- list_.at(index) = std::move(item);
- }
- void Print() {
- fprintf(stderr, "tensorlist\n");
- for (auto& item : list_) {
- fprintf(stderr, " item: %p\n", (void*)item.get());
- }
- }
- size_t Size() { return list_.size(); }
- absl::Span<int32_t> Shape() {
- return absl::Span<int32_t>(shape_.data(), shape_.size());
- }
-
- static StatusOr<vm::ref<TensorList>> FromTensor(
- vm::ref<iree_hal_buffer_view_t> tensor) {
- size_t rank = iree_hal_buffer_view_shape_rank(tensor.get());
- if (rank == 0) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "expected rank > 0 buffer view");
- }
- std::vector<iree_hal_dim_t> shape(rank);
- if (rank > 0) {
- IREE_RETURN_IF_ERROR(iree_hal_buffer_view_shape(tensor.get(), rank,
- shape.data(), nullptr));
- }
-
- auto element_type = iree_hal_buffer_view_element_type(tensor.get());
-
- int32_t list_elements = shape[0];
- absl::Span<int32_t> element_shape(shape.data() + 1, shape.size() - 1);
-
- TensorList* list = new TensorList(element_shape, element_type);
- list->Resize(list_elements);
-
- // The python pseudocode for this is:
- // for i in range(t.shape[0]):
- // list[i] = t[i,...]
- std::vector<int32_t> start_indices(shape.size());
- std::vector<int32_t> lengths = shape;
- lengths[0] = 1;
- for (int i = 0, e = list_elements; i < e; i++) {
- start_indices[0] = i;
- iree_device_size_t start_offset = 0;
- iree_device_size_t subview_length = 0;
- IREE_RETURN_IF_ERROR(iree_hal_buffer_view_compute_range(
- tensor.get(), start_indices.data(), start_indices.size(),
- lengths.data(), lengths.size(), &start_offset, &subview_length));
- vm::ref<iree_hal_buffer_t> subview_buffer;
- IREE_RETURN_IF_ERROR(iree_hal_buffer_subspan(
- iree_hal_buffer_view_buffer(tensor.get()), start_offset,
- subview_length, &subview_buffer));
-
- iree_hal_buffer_view_t* slice = nullptr;
- IREE_RETURN_IF_ERROR(iree_hal_buffer_view_create(
- subview_buffer.get(), element_shape.data(), element_shape.size(),
- iree_hal_buffer_view_element_type(tensor.get()), &slice));
- list->SetItem(i, slice);
- }
- return list;
- }
-
- StatusOr<vm::ref<iree_hal_buffer_view_t>> Stack(
- vm::ref<iree_hal_allocator_t> hal_allocator) {
- size_t num_tensors = Size();
- if (num_tensors == 0) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "expected non-empty list");
- }
-
- // Validate that all buffers are of the right shape/type.
- absl::Span<int32_t> shape(shape_);
- iree_hal_element_type_t type(dtype_);
- for (size_t i = 0; i < num_tensors; i++) {
- auto item = GetItem(i).get();
- if (!item) continue;
- size_t element_rank = iree_hal_buffer_view_shape_rank(item);
- std::vector<iree_hal_dim_t> element_shape(element_rank);
- if (element_rank > 0) {
- IREE_RETURN_IF_ERROR(iree_hal_buffer_view_shape(
- item, element_rank, element_shape.data(), nullptr));
- }
- if (absl::MakeSpan(shape) != absl::MakeSpan(element_shape) ||
- iree_hal_buffer_view_element_type(item) != type) {
- return iree_make_status(
- IREE_STATUS_INVALID_ARGUMENT,
- "stacking list with elements of different shapes or element types; "
- "mismatch between element 0 and element %zu",
- i);
- ;
- }
- }
-
- vm::ref<iree_hal_buffer_t> result_buffer;
- size_t num_elements_per_tensor = 1;
- for (int32_t dim : shape) {
- num_elements_per_tensor *= dim;
- }
-
- size_t element_size = iree_hal_element_byte_count(type);
- size_t num_result_elements = num_elements_per_tensor * num_tensors;
- size_t result_byte_size = num_result_elements * element_size;
- IREE_RETURN_IF_ERROR(iree_hal_allocator_allocate_buffer(
- hal_allocator.get(),
- static_cast<iree_hal_memory_type_t>(
- IREE_HAL_MEMORY_TYPE_HOST_LOCAL |
- IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE),
- IREE_HAL_BUFFER_USAGE_ALL, result_byte_size, &result_buffer));
-
- IREE_RETURN_IF_ERROR(CopyTensorBytes(result_buffer.get()));
-
- std::vector<int32_t> result_shape;
- result_shape.push_back(Size());
- for (int32_t dim : shape) {
- result_shape.push_back(dim);
- }
- vm::ref<iree_hal_buffer_view_t> result_view;
- IREE_RETURN_IF_ERROR(
- iree_hal_buffer_view_create(result_buffer.get(), result_shape.data(),
- result_shape.size(), type, &result_view));
- return std::move(result_view);
- }
-
- StatusOr<vm::ref<iree_hal_buffer_view_t>> Concat(
- vm::ref<iree_hal_allocator_t> hal_allocator) {
- size_t num_tensors = Size();
- if (num_tensors == 0) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "expected non-empty list");
- }
-
- if (shape_.empty()) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "stacking rank must be greater than zero");
- }
-
- size_t rank = iree_hal_buffer_view_shape_rank(GetItem(0).get());
- iree_hal_element_type_t type = dtype_;
- std::vector<iree_hal_dim_t> shape(rank);
- if (rank > 0) {
- IREE_RETURN_IF_ERROR(iree_hal_buffer_view_shape(GetItem(0).get(), rank,
- shape.data(), nullptr));
- }
- const size_t num_rows = num_tensors * shape[0];
- for (size_t i = 0; i < num_tensors; i++) {
- auto item = GetItem(i).get();
- if (!item) continue;
- size_t element_rank = iree_hal_buffer_view_shape_rank(item);
- if (element_rank < 1) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "stacking rank %zu must be greater than zero",
- i);
- }
-
- std::vector<iree_hal_dim_t> element_shape(element_rank);
- IREE_RETURN_IF_ERROR(iree_hal_buffer_view_shape(
- GetItem(i).get(), element_rank, element_shape.data(), nullptr));
-
- if (absl::MakeSpan(shape).subspan(1) !=
- absl::MakeSpan(element_shape).subspan(1) ||
- iree_hal_buffer_view_element_type(GetItem(i).get()) != type) {
- return iree_make_status(
- IREE_STATUS_INVALID_ARGUMENT,
- "stacking list with elements of different shapes or element types; "
- "mismatch between element 0 and element %zu",
- i);
- }
- }
-
- vm::ref<iree_hal_buffer_t> result_buffer;
- size_t num_elements_per_row = 1;
- for (int32_t dim : absl::MakeSpan(shape).subspan(1)) {
- num_elements_per_row *= dim;
- }
- size_t element_size = iree_hal_buffer_view_element_size(GetItem(0).get());
- size_t num_result_elements = num_elements_per_row * num_rows;
- size_t result_byte_size = num_result_elements * element_size;
- IREE_RETURN_IF_ERROR(iree_hal_allocator_allocate_buffer(
- hal_allocator.get(),
- static_cast<iree_hal_memory_type_t>(
- IREE_HAL_MEMORY_TYPE_HOST_LOCAL |
- IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE),
- IREE_HAL_BUFFER_USAGE_ALL, result_byte_size, &result_buffer));
-
- IREE_RETURN_IF_ERROR(CopyTensorBytes(result_buffer.get()));
-
- std::vector<int32_t> result_shape;
- result_shape.push_back(num_rows);
- for (int32_t dim : absl::MakeSpan(shape).subspan(1)) {
- result_shape.push_back(dim);
- }
- vm::ref<iree_hal_buffer_view_t> result_view;
- IREE_RETURN_IF_ERROR(
- iree_hal_buffer_view_create(result_buffer.get(), result_shape.data(),
- result_shape.size(), type, &result_view));
-
- return std::move(result_view);
- }
-
- private:
- iree_status_t CopyTensorBytes(iree_hal_buffer_t* buffer) {
- iree_hal_buffer_mapping_t result_mapping;
- iree_device_size_t dest_byte_size = iree_hal_buffer_byte_length(buffer);
- IREE_RETURN_IF_ERROR(iree_hal_buffer_map_range(
- buffer, IREE_HAL_MEMORY_ACCESS_WRITE,
- /*byte_offset=*/0,
- /*byte_length=*/dest_byte_size, &result_mapping));
-
- // Copy each buffer into the result at the right offset.
- // This is just a naive map+memcpy.
- // If this is a bottleneck, simply optimizing this code here locally is
- // probably not the best answer. A better solution will use
- // iree_hal_command_buffer_copy_buffer to do the copies, but that will
- // require changing this op signature to take a command buffer and to make
- // sure that each of the contained tensors have
- // IREE_HAL_BUFFER_USAGE_TRANSFER. Both of these will probably require
- // compiler changes. In fact, we might want to expand this operation fully
- // in the compiler at which point there will be no "stack" function inside
- // this module at all.
- size_t num_tensors = Size();
- size_t tensor_byte_size = iree_hal_element_byte_count(dtype_);
- for (auto dim : shape_) tensor_byte_size *= dim;
- for (size_t i = 0; i < num_tensors; i++) {
- iree_hal_buffer_view_t* tensor = GetItem(i).get();
-
- auto block_begin = result_mapping.contents.data + i * tensor_byte_size;
- auto block_size = tensor_byte_size;
-
- if (!tensor) {
- memset(block_begin, 0, block_size);
- continue;
- }
-
- iree_hal_buffer_t* tensor_buffer = iree_hal_buffer_view_buffer(tensor);
- IREE_RETURN_IF_ERROR(
- iree_hal_buffer_read_data(tensor_buffer, 0, block_begin, block_size));
- }
-
- iree_hal_buffer_unmap_range(&result_mapping);
- return iree_ok_status();
- }
-
- std::vector<vm::ref<iree_hal_buffer_view_t>> list_;
- std::vector<iree_hal_dim_t> shape_;
- iree_hal_element_type_t dtype_;
-};
-} // namespace
-
-//===----------------------------------------------------------------------===//
-// `tensorlist.list` VM type registration.
-//===----------------------------------------------------------------------===//
-
-static iree_vm_ref_type_descriptor_t iree_tensorlist_descriptor = {0};
-
-// Register our type with the vm::ref<T> static machinery.
-namespace vm {
-template <>
-struct ref_type_descriptor<TensorList> {
- static const iree_vm_ref_type_descriptor_t* get() {
- return &iree_tensorlist_descriptor;
- }
-};
-} // namespace vm
-
-extern "C" iree_status_t iree_tensorlist_module_register_types(void) {
- static bool has_registered = false;
- if (has_registered) return iree_ok_status();
- IREE_VM_REGISTER_CC_TYPE(TensorList, "tensorlist.list",
- iree_tensorlist_descriptor);
- return iree_ok_status();
-}
-
-//===----------------------------------------------------------------------===//
-// VM module interface implementation
-//===----------------------------------------------------------------------===//
-
-// Extremely low-performance helper for dealing with buffer views that
-// contain scalar int32_t's.
-// TODO(silvasean): Change relevant ops to just take a VM i32.
-// That will require doing a bit more work in the compiler for conversion.
-static StatusOr<int32_t> ReadInt32FromScalarBufferView(
- iree_hal_buffer_view_t* buffer_view) {
- if (iree_hal_buffer_view_element_type(buffer_view) !=
- IREE_HAL_ELEMENT_TYPE_SINT_32) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "expected i32 buffer view");
- }
- if (iree_hal_buffer_view_shape_rank(buffer_view) != 0) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "expected rank-0 buffer view");
- }
- iree_hal_buffer_t* buffer = iree_hal_buffer_view_buffer(buffer_view);
- iree_hal_buffer_mapping_t mapped_memory;
- IREE_RETURN_IF_ERROR(iree_hal_buffer_map_range(
- buffer, IREE_HAL_MEMORY_ACCESS_READ, 0, 4, &mapped_memory));
- int32_t scalar = *reinterpret_cast<int32_t*>(mapped_memory.contents.data);
- iree_hal_buffer_unmap_range(&mapped_memory);
- return scalar;
-}
-
-static StatusOr<std::vector<int32_t>> ReadInt32VectorFromBufferView(
- iree_hal_buffer_view_t* buffer_view) {
- if (iree_hal_buffer_view_element_type(buffer_view) !=
- IREE_HAL_ELEMENT_TYPE_SINT_32) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "expected i32 buffer view");
- }
- if (iree_hal_buffer_view_shape_rank(buffer_view) != 1) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "expected rank-1 buffer view");
- }
-
- int32_t length;
- IREE_RETURN_IF_ERROR(iree_hal_buffer_view_shape(
- buffer_view, /*rank_capacity=*/1, &length, nullptr));
-
- iree_hal_buffer_t* buffer = iree_hal_buffer_view_buffer(buffer_view);
- std::vector<int32_t> contents(length);
- IREE_RETURN_IF_ERROR(iree_hal_buffer_read_data(
- buffer, 0, contents.data(), contents.size() * sizeof(int32_t)));
- return contents;
-}
-
-namespace {
-class TensorListModuleState final {
- public:
- TensorListModuleState() = default;
- ~TensorListModuleState() = default;
-
- // tensorlist.reserve(%element_shape, %num_elements) -> %list
- StatusOr<vm::ref<TensorList>> Reserve(
- vm::ref<iree_hal_buffer_view_t> element_shape,
- vm::ref<iree_hal_buffer_view_t> num_elements_buf,
- iree_hal_element_type_t element_type) {
- IREE_ASSIGN_OR_RETURN(std::vector<iree_hal_dim_t> shape,
- ReadInt32VectorFromBufferView(element_shape.get()));
- TensorList* tensorlist = new TensorList(shape, element_type);
- IREE_ASSIGN_OR_RETURN(int32_t num_elements, ReadInt32FromScalarBufferView(
- num_elements_buf.get()));
- tensorlist->Resize(num_elements);
- return tensorlist;
- }
-
- // tensorlist.get_item(%list, %index, %element_shape) -> %item
- StatusOr<vm::ref<iree_hal_buffer_view_t>> GetItem(
- vm::ref<TensorList> tensorlist,
- vm::ref<iree_hal_buffer_view_t> index_buf) {
- IREE_ASSIGN_OR_RETURN(int32_t index,
- ReadInt32FromScalarBufferView(index_buf.get()));
- return vm::retain_ref(tensorlist->GetItem(index).get());
- }
-
- // tensorlist.set_item(%list, %index, %item) -> %new_list
- StatusOr<vm::ref<TensorList>> SetItem(
- vm::ref<TensorList> list, vm::ref<iree_hal_buffer_view_t> index_buf,
- vm::ref<iree_hal_buffer_view_t> item) {
- IREE_ASSIGN_OR_RETURN(int32_t index,
- ReadInt32FromScalarBufferView(index_buf.get()));
- TensorList* new_list = new TensorList(list);
- new_list->SetItem(index, vm::retain_ref(item));
- return new_list;
- }
-
- // tensorlist.from_tensor(%tensor, %element_shape) -> %list
- StatusOr<vm::ref<TensorList>> FromTensor(
- vm::ref<iree_hal_buffer_view_t> tensor) {
- return TensorList::FromTensor(tensor);
- }
-
- // tensorlist.concat(%list) -> %list
- StatusOr<vm::ref<iree_hal_buffer_view_t>> Concat(
- vm::ref<iree_hal_allocator_t> allocator, vm::ref<TensorList> list) {
- return list->Concat(allocator);
- }
-
- // tensorlist.stack(%list, %element_shape, %num_elements) -> %list
- StatusOr<vm::ref<iree_hal_buffer_view_t>> Stack(
- vm::ref<iree_hal_allocator_t> allocator, vm::ref<TensorList> list,
- vm::ref<iree_hal_buffer_view_t> num_elements_buffer_view) {
- IREE_ASSIGN_OR_RETURN(
- int32_t num_elements,
- ReadInt32FromScalarBufferView(num_elements_buffer_view.get()));
- if (num_elements != -1 && list->Size() != num_elements) {
- return iree_make_status(
- IREE_STATUS_INVALID_ARGUMENT,
- "num_elements arg to tesorlist.stack doesn't match the list "
- "size");
- }
- return list->Stack(allocator);
- }
-};
-} // namespace
-
-static const vm::NativeFunction<TensorListModuleState>
- kTensorListModuleFunctions[] = {
- vm::MakeNativeFunction("reserve", &TensorListModuleState::Reserve),
- vm::MakeNativeFunction("get_item", &TensorListModuleState::GetItem),
- vm::MakeNativeFunction("set_item", &TensorListModuleState::SetItem),
- vm::MakeNativeFunction("from_tensor",
- &TensorListModuleState::FromTensor),
- vm::MakeNativeFunction("concat", &TensorListModuleState::Concat),
- vm::MakeNativeFunction("stack", &TensorListModuleState::Stack),
-};
-
-namespace {
-class TensorListModule final : public vm::NativeModule<TensorListModuleState> {
- public:
- using vm::NativeModule<TensorListModuleState>::NativeModule;
-
- // Creates per-context state when the module is added to a new context.
- // May be called from any thread.
- StatusOr<std::unique_ptr<TensorListModuleState>> CreateState(
- iree_allocator_t allocator) override {
- auto state = std::make_unique<TensorListModuleState>();
- return state;
- }
-};
-} // namespace
-
-extern "C" iree_status_t iree_tensorlist_module_create(
- iree_allocator_t allocator, iree_vm_module_t** out_module) {
- if (!out_module) return iree_make_status(IREE_STATUS_INVALID_ARGUMENT);
- *out_module = NULL;
- auto module = std::make_unique<TensorListModule>(
- "tensorlist", allocator, absl::MakeConstSpan(kTensorListModuleFunctions));
- *out_module = module.release()->interface();
- return iree_ok_status();
-}
-
-} // namespace iree
diff --git a/iree/modules/tensorlist/native_module.h b/iree/modules/tensorlist/native_module.h
deleted file mode 100644
index bddc2eb..0000000
--- a/iree/modules/tensorlist/native_module.h
+++ /dev/null
@@ -1,33 +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
-
-#ifndef IREE_MODULES_TENSORLIST_NATIVE_MODULE_H_
-#define IREE_MODULES_TENSORLIST_NATIVE_MODULE_H_
-
-#include <stdint.h>
-
-#include "iree/base/api.h"
-#include "iree/vm/api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-// Registers the custom types used by the module.
-// WARNING: not thread-safe; call at startup before using.
-iree_status_t iree_tensorlist_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_tensorlist_module_create(iree_allocator_t allocator,
- iree_vm_module_t** out_module);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cplusplus
-
-#endif // IREE_MODULES_TENSORLIST_NATIVE_MODULE_H_
diff --git a/iree/modules/tensorlist/tensorlist_test.cc b/iree/modules/tensorlist/tensorlist_test.cc
deleted file mode 100644
index 596bd10..0000000
--- a/iree/modules/tensorlist/tensorlist_test.cc
+++ /dev/null
@@ -1,224 +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
-
-// Tests that our bytecode module can call through into our native module.
-
-#include <vector>
-
-#include "absl/types/span.h"
-#include "iree/base/api.h"
-#include "iree/base/logging.h"
-#include "iree/hal/api.h"
-#include "iree/hal/vmvx/registration/driver_module.h"
-#include "iree/modules/hal/hal_module.h"
-#include "iree/modules/tensorlist/native_module.h"
-#include "iree/modules/tensorlist/tensorlist_test_module_c.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"
-
-namespace iree {
-
-namespace {
-
-class TensorListModulesTest : 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_CHECK_OK(iree_hal_driver_create_default_device(
- hal_driver, iree_allocator_system(), &device_));
- IREE_CHECK_OK(
- iree_hal_module_create(device_, iree_allocator_system(), &hal_module_));
- iree_hal_driver_release(hal_driver);
-
- IREE_CHECK_OK(iree_tensorlist_module_register_types());
- IREE_CHECK_OK(iree_tensorlist_module_create(iree_allocator_system(),
- &native_module_));
-
- const auto* module_file_toc = iree_tensorlist_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_, modules.data(), modules.size(), iree_allocator_system(),
- &context_));
- }
-
- virtual void TearDown() {
- iree_hal_device_release(device_);
- iree_vm_module_release(native_module_);
- iree_vm_module_release(bytecode_module_);
- iree_vm_module_release(hal_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;
- }
-
- void Invoke(const char* function_name, absl::Span<const float> input_values,
- absl::Span<const int32_t> input_shape,
- absl::Span<const float> expected_values,
- absl::Span<const int32_t> expected_shape) {
- vm::ref<iree_hal_buffer_view_t> input_buffer_view;
- CreateBufferView(input_values, input_shape, device_, &input_buffer_view);
-
- // Pass in the tensor as a HAL buffer view.
- 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(input_buffer_view.get());
- IREE_ASSERT_OK(
- iree_vm_list_push_ref_retain(inputs.get(), &input_buffer_view_ref));
-
- // Prepare outputs list to accept the results from the invocation.
- 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(function_name),
- /*policy=*/nullptr, inputs.get(),
- outputs.get(), iree_allocator_system()));
-
- auto* returned_buffer_view =
- reinterpret_cast<iree_hal_buffer_view_t*>(iree_vm_list_get_ref_deref(
- outputs.get(), 0, iree_hal_buffer_view_get_descriptor()));
-
- std::vector<int32_t> returned_shape(
- iree_hal_buffer_view_shape_rank(returned_buffer_view));
- if (returned_shape.size() > 0) {
- iree_hal_buffer_view_shape(returned_buffer_view, returned_shape.size(),
- returned_shape.data(), nullptr);
- }
-
- EXPECT_EQ(returned_shape, expected_shape);
-
- iree_hal_buffer_t* returned_buffer =
- iree_hal_buffer_view_buffer(returned_buffer_view);
- ASSERT_NE(returned_buffer, nullptr);
-
- iree_hal_buffer_mapping_t mapped_memory;
- IREE_ASSERT_OK(
- iree_hal_buffer_map_range(returned_buffer, IREE_HAL_MEMORY_ACCESS_READ,
- 0, IREE_WHOLE_BUFFER, &mapped_memory));
- for (int i = 0; i < expected_values.size(); i++) {
- EXPECT_EQ(reinterpret_cast<float*>(mapped_memory.contents.data)[i],
- expected_values[i]);
- }
-
- iree_hal_buffer_unmap_range(&mapped_memory);
- }
-
- void CreateBufferView(absl::Span<const float> contents,
- absl::Span<const int32_t> shape,
- iree_hal_device_t* device,
- iree_hal_buffer_view_t** out_buffer_view) {
- size_t num_elements = 1;
- for (int32_t dim : shape) {
- num_elements *= dim;
- }
- ASSERT_EQ(contents.size(), num_elements);
- vm::ref<iree_hal_buffer_t> buffer;
- iree_hal_allocator_t* allocator = iree_hal_device_allocator(device);
- IREE_ASSERT_OK(iree_hal_allocator_allocate_buffer(
- allocator,
- static_cast<iree_hal_memory_type_t>(
- IREE_HAL_MEMORY_TYPE_HOST_LOCAL |
- IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE),
- IREE_HAL_BUFFER_USAGE_ALL, contents.size() * sizeof(float), &buffer));
- IREE_ASSERT_OK(iree_hal_buffer_write_data(buffer.get(), 0, contents.data(),
- contents.size() * sizeof(float)));
- IREE_ASSERT_OK(iree_hal_buffer_view_create(
- buffer.get(), shape.data(), shape.size(),
- IREE_HAL_ELEMENT_TYPE_FLOAT_32, &*out_buffer_view));
- }
-
- iree_hal_device_t* device_ = nullptr;
- 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;
-};
-
-TEST_F(TensorListModulesTest, IdentityThroughSetItemGetItem) {
- // Allocate the buffer we'll be passing through.
- std::vector<float> input = {42.0f};
- std::vector<int32_t> input_shape = {};
- Invoke("identity_through_set_item_get_item", input, input_shape, input,
- input_shape);
-}
-
-TEST_F(TensorListModulesTest, IdentityThroughSetItemGetItem2D) {
- // Allocate the buffer we'll be passing through.
- std::vector<float> input = {42.0f};
- std::vector<int32_t> input_shape = {1, 1};
- Invoke("identity_through_set_item_get_item", input, input_shape, input,
- input_shape);
-}
-
-TEST_F(TensorListModulesTest, IdentityThroughConcat) {
- // Allocate the buffer we'll be passing through.
- std::vector<float> input = {42.0f, 43.0f, 44.0f, 45.0f};
- std::vector<int32_t> input_shape = {4, 1};
- std::vector<int32_t> expected_shape = {4};
- Invoke("identity_through_concat", input, input_shape, input, expected_shape);
-}
-
-TEST_F(TensorListModulesTest, ConcatAppendsEmpty) {
- // Allocate the buffer we'll be passing through.
- std::vector<float> input = {42.0f};
- std::vector<int32_t> input_shape = {1};
- std::vector<float> expected = {42.0f, 0.0f};
- std::vector<int32_t> expected_shape = {2};
- Invoke("concat_appends_empty", input, input_shape, expected, expected_shape);
-}
-
-TEST_F(TensorListModulesTest, IdentityThroughStack) {
- // Allocate the buffer we'll be passing through.
- std::vector<float> input = {42.0f, 43.0f};
- std::vector<int32_t> input_shape = {2, 1};
- Invoke("identity_through_stack", input, input_shape, input, input_shape);
-}
-
-TEST_F(TensorListModulesTest, StackAppendsEmpty) {
- // Allocate the buffer we'll be passing through.
- std::vector<float> input = {42.0f};
- std::vector<int32_t> input_shape = {};
- std::vector<float> expected = {42.0f, 0.0f};
- std::vector<int32_t> expected_shape = {2};
- Invoke("stack_appends_empty", input, input_shape, expected, expected_shape);
-}
-
-} // namespace
-} // namespace iree
diff --git a/iree/modules/tensorlist/tensorlist_test.mlir b/iree/modules/tensorlist/tensorlist_test.mlir
deleted file mode 100644
index ebf2fce..0000000
--- a/iree/modules/tensorlist/tensorlist_test.mlir
+++ /dev/null
@@ -1,93 +0,0 @@
-func @identity_through_set_item_get_item(%arg0: !hal.buffer_view) -> !hal.buffer_view attributes {iree.module.export, iree.abi.none} {
- %device = hal.ex.shared_device : !hal.device
- %allocator = hal.device.allocator<%device : !hal.device> : !hal.allocator
- %0 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<1> : tensor<i32>
- %1 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<[]> : tensor<0xi32>
- %2 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<0> : tensor<i32>
- %3 = "tensorlist.Reserve"(%1, %0) { element_type = 50331680 : i32} : (!hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- %4 = "tensorlist.SetItem"(%3, %2, %arg0) : (!tensorlist.list, !hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- %5 = "tensorlist.GetItem"(%4, %2) : (!tensorlist.list, !hal.buffer_view) -> !hal.buffer_view
- return %5 : !hal.buffer_view
-}
-
-func @identity_through_set_item_get_item_2D(%arg0: !hal.buffer_view) -> !hal.buffer_view attributes {iree.module.export, iree.abi.none} {
- %device = hal.ex.shared_device : !hal.device
- %allocator = hal.device.allocator<%device : !hal.device> : !hal.allocator
- %0 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<1> : tensor<i32>
- %1 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<[1, 1]> : tensor<2xi32>
- %2 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<0> : tensor<i32>
- %3 = "tensorlist.Reserve"(%1, %0) { element_type = 50331680 : i32} : (!hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- %4 = "tensorlist.SetItem"(%3, %2, %arg0) : (!tensorlist.list, !hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- %stacked = "tensorlist.Stack"(%allocator, %4, %0) : (!hal.allocator, !tensorlist.list, !hal.buffer_view) -> !hal.buffer_view
- return %stacked : !hal.buffer_view
-}
-
-func @identity_through_concat(%arg0: !hal.buffer_view) -> !hal.buffer_view attributes {iree.module.export, iree.abi.none} {
- %device = hal.ex.shared_device : !hal.device
- %allocator = hal.device.allocator<%device : !hal.device> : !hal.allocator
- %element_shape = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<[]> : tensor<0xi32>
- %list = "tensorlist.FromTensor"(%arg0) : (!hal.buffer_view) -> !tensorlist.list
- %concat = "tensorlist.Concat"(%allocator, %list) : (!hal.allocator, !tensorlist.list) -> !hal.buffer_view
- return %concat : !hal.buffer_view
-}
-
-func @concat_appends_empty(%arg0: !hal.buffer_view) -> !hal.buffer_view attributes {iree.module.export, iree.abi.none} {
- %device = hal.ex.shared_device : !hal.device
- %allocator = hal.device.allocator<%device : !hal.device> : !hal.allocator
- %0 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<2> : tensor<i32>
- %1 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<[1]> : tensor<1xi32>
- %2 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<0> : tensor<i32>
- %3 = "tensorlist.Reserve"(%1, %0) { element_type = 50331680 : i32} : (!hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- %4 = "tensorlist.SetItem"(%3, %2, %arg0) : (!tensorlist.list, !hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- %concat = "tensorlist.Concat"(%allocator, %4) : (!hal.allocator, !tensorlist.list) -> !hal.buffer_view
- return %concat : !hal.buffer_view
-}
-
-func @identity_through_stack(%arg0: !hal.buffer_view) -> !hal.buffer_view attributes {iree.module.export, iree.abi.none} {
- %device = hal.ex.shared_device : !hal.device
- %allocator = hal.device.allocator<%device : !hal.device> : !hal.allocator
- %num_elements = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<2> : tensor<i32>
- %list = "tensorlist.FromTensor"(%arg0) : (!hal.buffer_view) -> !tensorlist.list
- %stacked = "tensorlist.Stack"(%allocator, %list, %num_elements) : (!hal.allocator, !tensorlist.list, !hal.buffer_view) -> !hal.buffer_view
- return %stacked : !hal.buffer_view
-}
-
-func @stack_appends_empty(%arg0: !hal.buffer_view) -> !hal.buffer_view attributes {iree.module.export, iree.abi.none} {
- %device = hal.ex.shared_device : !hal.device
- %allocator = hal.device.allocator<%device : !hal.device> : !hal.allocator
- %0 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<2> : tensor<i32>
- %1 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<[]> : tensor<0xi32>
- %2 = hal.allocator.constant<%allocator : !hal.allocator>
- type("HostLocal|DeviceVisible") usage("All") : !hal.buffer_view =
- dense<0> : tensor<i32>
- %3 = "tensorlist.Reserve"(%1, %0) { element_type = 50331680 : i32} : (!hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- %4 = "tensorlist.SetItem"(%3, %2, %arg0) : (!tensorlist.list, !hal.buffer_view, !hal.buffer_view) -> !tensorlist.list
- %stacked = "tensorlist.Stack"(%allocator, %4, %0) : (!hal.allocator, !tensorlist.list, !hal.buffer_view) -> !hal.buffer_view
- return %stacked : !hal.buffer_view
-}
diff --git a/iree/tools/BUILD b/iree/tools/BUILD
index d3a90a0..a1b0bc9 100644
--- a/iree/tools/BUILD
+++ b/iree/tools/BUILD
@@ -158,8 +158,6 @@
hdrs = ["init_compiler_modules.h"],
deps = [
"//iree/compiler/Dialect/Modules/Check/IR:CheckDialect",
- "//iree/compiler/Dialect/Modules/Strings/IR:Dialect",
- "//iree/compiler/Dialect/Modules/TensorList/IR:TensorListDialect",
],
)
diff --git a/iree/tools/CMakeLists.txt b/iree/tools/CMakeLists.txt
index a51be21..1ddfa72 100644
--- a/iree/tools/CMakeLists.txt
+++ b/iree/tools/CMakeLists.txt
@@ -237,8 +237,6 @@
"init_compiler_modules.h"
DEPS
iree::compiler::Dialect::Modules::Check::IR::CheckDialect
- iree::compiler::Dialect::Modules::Strings::IR::Dialect
- iree::compiler::Dialect::Modules::TensorList::IR::TensorListDialect
)
iree_cc_library(
diff --git a/iree/tools/init_compiler_modules.h b/iree/tools/init_compiler_modules.h
index a53de81..b492ffd 100644
--- a/iree/tools/init_compiler_modules.h
+++ b/iree/tools/init_compiler_modules.h
@@ -8,8 +8,6 @@
#define IREE_TOOLS_INIT_COMPILER_MODULES_H_
#include "iree/compiler/Dialect/Modules/Check/IR/CheckDialect.h"
-#include "iree/compiler/Dialect/Modules/Strings/IR/Dialect.h"
-#include "iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.h"
namespace mlir {
namespace iree_compiler {
@@ -17,9 +15,7 @@
// Add all the IREE compiler module dialects to the provided registry.
inline void registerIreeCompilerModuleDialects(DialectRegistry ®istry) {
// clang-format off
- registry.insert<IREE::Check::CheckDialect,
- IREE::Strings::StringsDialect,
- IREE::TensorList::TensorListDialect>();
+ registry.insert<IREE::Check::CheckDialect>();
// clang-format on
}