Add python bindings for IREE internal dialects. (#14770)

I've been running into these recently when wanting to create helper
scripts. Also some of these will be helpful for Turbine.
diff --git a/compiler/bindings/python/CMakeLists.txt b/compiler/bindings/python/CMakeLists.txt
index 206c085..ea89d0b 100644
--- a/compiler/bindings/python/CMakeLists.txt
+++ b/compiler/bindings/python/CMakeLists.txt
@@ -50,6 +50,51 @@
 # Sources
 ################################################################################
 
+declare_mlir_python_sources(IREEPythonSources)
+declare_mlir_python_sources(IREEPythonSources.Dialects
+  ADD_TO_PARENT IREEPythonSources
+)
+
+declare_mlir_dialect_python_bindings(
+  ADD_TO_PARENT IREEPythonSources.Dialects
+  ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/iree/compiler"
+  TD_FILE dialects/FlowBinding.td
+  SOURCES dialects/flow.py
+  DIALECT_NAME flow
+)
+
+declare_mlir_dialect_python_bindings(
+  ADD_TO_PARENT IREEPythonSources.Dialects
+  ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/iree/compiler"
+  TD_FILE dialects/HALBinding.td
+  SOURCES dialects/hal.py
+  DIALECT_NAME hal
+)
+
+declare_mlir_dialect_python_bindings(
+  ADD_TO_PARENT IREEPythonSources.Dialects
+  ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/iree/compiler"
+  TD_FILE dialects/StreamBinding.td
+  SOURCES dialects/stream.py
+  DIALECT_NAME stream
+)
+
+declare_mlir_dialect_python_bindings(
+  ADD_TO_PARENT IREEPythonSources.Dialects
+  ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/iree/compiler"
+  TD_FILE dialects/UtilBinding.td
+  SOURCES dialects/util.py
+  DIALECT_NAME util
+)
+
+declare_mlir_dialect_python_bindings(
+  ADD_TO_PARENT IREEPythonSources.Dialects
+  ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/iree/compiler"
+  TD_FILE dialects/VMBinding.td
+  SOURCES dialects/vm.py
+  DIALECT_NAME vm
+)
+
 declare_mlir_python_sources(IREECompilerAPIPythonTools
   ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/iree/compiler"
   SOURCES
@@ -88,6 +133,7 @@
   # Local sources.
   IREECompilerAPIPythonTools
   IREECompilerPythonExtensions
+  IREEPythonSources
 
   MLIRPythonSources.Core
 
diff --git a/compiler/bindings/python/iree/compiler/dialects/FlowBinding.td b/compiler/bindings/python/iree/compiler/dialects/FlowBinding.td
new file mode 100644
index 0000000..5fd404f
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/FlowBinding.td
@@ -0,0 +1,12 @@
+// Copyright 2023 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 PYTHON_BINDINGS_FLOW_OPS
+#define PYTHON_BINDINGS_FLOW_OPS
+
+include "iree/compiler/Dialect/Flow/IR/FlowOps.td"
+
+#endif // PYTHON_BINDINGS_FLOW_OPS
diff --git a/compiler/bindings/python/iree/compiler/dialects/HALBinding.td b/compiler/bindings/python/iree/compiler/dialects/HALBinding.td
new file mode 100644
index 0000000..278d83e
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/HALBinding.td
@@ -0,0 +1,12 @@
+// Copyright 2023 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 PYTHON_BINDINGS_HAL_OPS
+#define PYTHON_BINDINGS_HAL_OPS
+
+include "iree/compiler/Dialect/HAL/IR/HALOps.td"
+
+#endif // PYTHON_BINDINGS_HAL_OPS
diff --git a/compiler/bindings/python/iree/compiler/dialects/StreamBinding.td b/compiler/bindings/python/iree/compiler/dialects/StreamBinding.td
new file mode 100644
index 0000000..7d74e32
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/StreamBinding.td
@@ -0,0 +1,12 @@
+// Copyright 2023 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 PYTHON_BINDINGS_STREAM_OPS
+#define PYTHON_BINDINGS_STREAM_OPS
+
+include "iree/compiler/Dialect/Stream/IR/StreamOps.td"
+
+#endif // PYTHON_BINDINGS_STREAM_OPS
diff --git a/compiler/bindings/python/iree/compiler/dialects/UtilBinding.td b/compiler/bindings/python/iree/compiler/dialects/UtilBinding.td
new file mode 100644
index 0000000..e574f3f
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/UtilBinding.td
@@ -0,0 +1,12 @@
+// Copyright 2023 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 PYTHON_BINDINGS_UTIL_OPS
+#define PYTHON_BINDINGS_UTIL_OPS
+
+include "iree/compiler/Dialect/Util/IR/UtilOps.td"
+
+#endif // PYTHON_BINDINGS_UTIL_OPS
diff --git a/compiler/bindings/python/iree/compiler/dialects/VMBinding.td b/compiler/bindings/python/iree/compiler/dialects/VMBinding.td
new file mode 100644
index 0000000..3100053
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/VMBinding.td
@@ -0,0 +1,12 @@
+// Copyright 2023 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 PYTHON_BINDINGS_VM_OPS
+#define PYTHON_BINDINGS_VM_OPS
+
+include "iree/compiler/Dialect/VM/IR/VMOps.td"
+
+#endif // PYTHON_BINDINGS_VM_OPS
diff --git a/compiler/bindings/python/iree/compiler/dialects/flow.py b/compiler/bindings/python/iree/compiler/dialects/flow.py
new file mode 100644
index 0000000..6139982
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/flow.py
@@ -0,0 +1,7 @@
+# Copyright 2023 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 ._flow_ops_gen import *
diff --git a/compiler/bindings/python/iree/compiler/dialects/hal.py b/compiler/bindings/python/iree/compiler/dialects/hal.py
new file mode 100644
index 0000000..340c2c2
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/hal.py
@@ -0,0 +1,7 @@
+# Copyright 2023 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 ._hal_ops_gen import *
diff --git a/compiler/bindings/python/iree/compiler/dialects/stream.py b/compiler/bindings/python/iree/compiler/dialects/stream.py
new file mode 100644
index 0000000..095c532
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/stream.py
@@ -0,0 +1,7 @@
+# Copyright 2023 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 ._stream_ops_gen import *
diff --git a/compiler/bindings/python/iree/compiler/dialects/util.py b/compiler/bindings/python/iree/compiler/dialects/util.py
new file mode 100644
index 0000000..858c722
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/util.py
@@ -0,0 +1,7 @@
+# Copyright 2023 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 ._util_ops_gen import *
diff --git a/compiler/bindings/python/iree/compiler/dialects/vm.py b/compiler/bindings/python/iree/compiler/dialects/vm.py
new file mode 100644
index 0000000..12c144e
--- /dev/null
+++ b/compiler/bindings/python/iree/compiler/dialects/vm.py
@@ -0,0 +1,7 @@
+# Copyright 2023 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 ._vm_ops_gen import *
diff --git a/compiler/bindings/python/test/ir/CMakeLists.txt b/compiler/bindings/python/test/ir/CMakeLists.txt
index c49e26d..fcf7b13 100644
--- a/compiler/bindings/python/test/ir/CMakeLists.txt
+++ b/compiler/bindings/python/test/ir/CMakeLists.txt
@@ -11,3 +11,9 @@
     "registration_test.py"
 )
 
+iree_py_test(
+  NAME
+    dialects_test
+  SRCS
+    "dialects_test.py"
+)
diff --git a/compiler/bindings/python/test/ir/dialects_test.py b/compiler/bindings/python/test/ir/dialects_test.py
new file mode 100644
index 0000000..63a9603
--- /dev/null
+++ b/compiler/bindings/python/test/ir/dialects_test.py
@@ -0,0 +1,16 @@
+# Copyright 2023 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 iree.compiler import ir
+
+# Make sure that our dialects import.
+from iree.compiler.dialects import (
+    flow,
+    hal,
+    stream,
+    vm,
+    util,
+)