Merge pull request #3142 from ScottTodd:main-to-google PiperOrigin-RevId: 331661857
diff --git a/SUBMODULE_VERSIONS b/SUBMODULE_VERSIONS index bb781a6..e627918 100644 --- a/SUBMODULE_VERSIONS +++ b/SUBMODULE_VERSIONS
@@ -4,7 +4,7 @@ a5d9d0f7d368054fd1691aedf1db4116efcc233e third_party/flatbuffers 4fb0ff7069bd88ee85902f4d0bb62794e5f6d021 third_party/flatcc f2fb48c3b3d79a75a88a99fba6576b25d42ec528 third_party/googletest -009cd4e491033f57f547a7bda63e35b50a6e5cf7 third_party/llvm-project +7841e21c98495ba5e33e0d2507d985bd5b938445 third_party/llvm-project 17b12a4481daa150e2d1ea3ada086b551b856707 third_party/marl 560cd8c94495409cbeacb31c0b907b5068adc45b third_party/mlir-emitc d8c7ee00a687ac369e62e2032514a93a9b413502 third_party/pybind11 @@ -12,7 +12,7 @@ a1390ed39ec77ecfb574bc6fcd5bfc5e3adbdea9 third_party/sdl2 f8bf11a0253a32375c32cad92c841237b96696c0 third_party/spirv_headers 57eb48aed36160c4876bc8310d9ca84d42ee9e2a third_party/swiftshader -ef9971b6d7a1bba53a8d067c6fa092a998892b29 third_party/tensorflow +86b67b8c829a5a5c61af396ce20ae60e63d9514a third_party/tensorflow 864d86e8b6d21449474db5e9313dbff90aa9c24f third_party/tracy 9bd3f561bcee3f01d22912de10bb07ce4e23d378 third_party/vulkan_headers 909f36b714c9239ee0b112a321220213a474ba53 third_party/vulkan_memory_allocator
diff --git a/build_tools/bazel/third_party_import/llvm-project/overlay/llvm/BUILD.bazel b/build_tools/bazel/third_party_import/llvm-project/overlay/llvm/BUILD.bazel index 314a81c..c8f1c08 100644 --- a/build_tools/bazel/third_party_import/llvm-project/overlay/llvm/BUILD.bazel +++ b/build_tools/bazel/third_party_import/llvm-project/overlay/llvm/BUILD.bazel
@@ -548,6 +548,8 @@ ("-gen-callingconv", "lib/Target/PowerPC/PPCGenCallingConv.inc"), ("-gen-subtarget", "lib/Target/PowerPC/PPCGenSubtargetInfo.inc"), ("-gen-disassembler", "lib/Target/PowerPC/PPCGenDisassemblerTables.inc"), + ("-gen-register-bank", "lib/Target/PowerPC/PPCGenRegisterBank.inc"), + ("-gen-global-isel", "lib/Target/PowerPC/PPCGenGlobalISel.inc"), ], }, { @@ -650,6 +652,7 @@ ":common_target_td_sources", ] + glob([ "lib/Target/" + target["dir_name"] + "/*.td", + "lib/Target/" + target["name"] + "/GISel/*.td", ]), deps = target.get("tbl_deps", []), ) for target in llvm_target_list] @@ -3383,6 +3386,7 @@ "lib/Target/PowerPC/*.c", "lib/Target/PowerPC/*.cpp", "lib/Target/PowerPC/*.inc", + "lib/Target/PowerPC/GISel/*.cpp", ]), hdrs = glob([ "include/llvm/Target/PowerPC/*.h", @@ -3396,6 +3400,7 @@ ":AsmPrinter", ":CodeGen", ":Core", + ":GlobalISel", ":MC", ":PowerPCDesc", ":PowerPCInfo",
diff --git a/build_tools/bazel/third_party_import/llvm-project/overlay/mlir/BUILD.bazel b/build_tools/bazel/third_party_import/llvm-project/overlay/mlir/BUILD.bazel index 1f6d5e7..1834744 100644 --- a/build_tools/bazel/third_party_import/llvm-project/overlay/mlir/BUILD.bazel +++ b/build_tools/bazel/third_party_import/llvm-project/overlay/mlir/BUILD.bazel
@@ -982,7 +982,6 @@ ], includes = ["include"], deps = [ - ":Analysis", ":IR", ":ParserTokenKinds", ":Support", @@ -2682,6 +2681,7 @@ ":Affine", ":CallOpInterfaces", ":IR", + ":LinalgOps", ":SCFDialect", ":StandardOps", ":Support", @@ -3923,6 +3923,7 @@ "include/mlir/Interfaces/CallInterfaces.td", "include/mlir/Interfaces/ControlFlowInterfaces.h", "include/mlir/Interfaces/ControlFlowInterfaces.td", + "include/mlir/Interfaces/CopyOpInterface.td", "include/mlir/Interfaces/SideEffectInterfaces.td", "include/mlir/Interfaces/VectorInterfaces.td", "include/mlir/Interfaces/ViewLikeInterface.td",
diff --git a/build_tools/bazel/third_party_import/llvm-project/overlay/mlir/test/BUILD.bazel b/build_tools/bazel/third_party_import/llvm-project/overlay/mlir/test/BUILD.bazel index 2ed9496..eab6f3f 100644 --- a/build_tools/bazel/third_party_import/llvm-project/overlay/mlir/test/BUILD.bazel +++ b/build_tools/bazel/third_party_import/llvm-project/overlay/mlir/test/BUILD.bazel
@@ -129,13 +129,16 @@ "lib/IR/TestPrintDefUse.cpp", "lib/IR/TestPrintNesting.cpp", "lib/IR/TestSideEffects.cpp", + "lib/IR/TestSlicing.cpp", "lib/IR/TestSymbolUses.cpp", "lib/IR/TestTypes.cpp", ], deps = [ ":TestDialect", "@llvm-project//llvm:Support", + "@llvm-project//mlir:Analysis", "@llvm-project//mlir:IR", + "@llvm-project//mlir:LinalgOps", "@llvm-project//mlir:Pass", "@llvm-project//mlir:StandardOps", "@llvm-project//mlir:Support",
diff --git a/build_tools/docker/manage_images.py b/build_tools/docker/manage_images.py index 8b9045a..9e7b7e3 100755 --- a/build_tools/docker/manage_images.py +++ b/build_tools/docker/manage_images.py
@@ -31,7 +31,8 @@ python3 build_tools/docker/manage_images.py --push --tag prod --images all Rebuild and push all images and update references to them in the repository: - python3 build_tools/docker/manage_images.py --push --images all --update-references + python3 build_tools/docker/manage_images.py --push --images all + --update-references """ import argparse @@ -73,12 +74,13 @@ """Parses command-line options.""" parser = argparse.ArgumentParser( description="Build IREE's Docker images and optionally push them to GCR.") - parser.add_argument('--images', - '--image', - type=str, - required=True, - action='append', - help=f'Name of the image to build: {IMAGES_HELP}.') + parser.add_argument( + '--images', + '--image', + type=str, + required=True, + action='append', + help=f'Name of the image to build: {IMAGES_HELP}.') parser.add_argument( '--tag', type=str, @@ -86,12 +88,14 @@ help='Tag for the images to build. Defaults to `latest` (which is good ' 'for testing changes in a PR). Use `prod` to update the images that the ' 'CI caches.') - parser.add_argument('--pull', - action='store_true', - help='Pull the specified image before building.') - parser.add_argument('--build', - action='store_true', - help='Build new images from the current Dockerfiles.') + parser.add_argument( + '--pull', + action='store_true', + help='Pull the specified image before building.') + parser.add_argument( + '--build', + action='store_true', + help='Build new images from the current Dockerfiles.') parser.add_argument( '--push', action='store_true', @@ -146,11 +150,12 @@ print(f'Running: `{" ".join(command)}`') if dry_run: return 0 - process = subprocess.Popen(command, - bufsize=1, - stderr=subprocess.STDOUT, - stdout=subprocess.PIPE, - universal_newlines=True) + process = subprocess.Popen( + command, + bufsize=1, + stderr=subprocess.STDOUT, + stdout=subprocess.PIPE, + universal_newlines=True) for line in process.stdout: print(line, end='') @@ -175,11 +180,12 @@ '-f', '{{index .RepoDigests 0}}', ] - inspect_process = subprocess.run(inspect_command, - universal_newlines=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - timeout=10) + inspect_process = subprocess.run( + inspect_command, + universal_newlines=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + timeout=10) if inspect_process.returncode != 0: print(f'Computing the repository digest for {image} failed.' ' Has it been pushed to GCR?') @@ -204,11 +210,12 @@ print(f'Updating references to {image_name}') grep_command = ['git', 'grep', '-l', f'{image_name}@sha256'] - grep_process = subprocess.run(grep_command, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - timeout=5, - universal_newlines=True) + grep_process = subprocess.run( + grep_command, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + timeout=5, + universal_newlines=True) if grep_process.returncode > 1: print(f'{" ".join(grep_command)} ' f'failed with exit code {grep_process.returncode}') @@ -220,9 +227,10 @@ files = grep_process.stdout.split() print(f'Updating references in {len(files)} files: {files}') for line in fileinput.input(files=files, inplace=(not dry_run)): - print(re.sub(f'{image_name}@sha256:[a-zA-Z0-9]+', f'{image_name}@{digest}', - line), - end='') + print( + re.sub(f'{image_name}@sha256:[a-zA-Z0-9]+', f'{image_name}@{digest}', + line), + end='') if __name__ == '__main__':
diff --git a/build_tools/third_party/tensorflow/tensorflow/compiler/mlir/hlo/CMakeLists.txt b/build_tools/third_party/tensorflow/tensorflow/compiler/mlir/hlo/CMakeLists.txt index c6d0125..917a486 100644 --- a/build_tools/third_party/tensorflow/tensorflow/compiler/mlir/hlo/CMakeLists.txt +++ b/build_tools/third_party/tensorflow/tensorflow/compiler/mlir/hlo/CMakeLists.txt
@@ -85,6 +85,7 @@ MLIRTransformUtils MLIRViewLikeInterface tensorflow_mlir_hlo_chlo_ops_gen + tensorflow_mlir_hlo_chlo_legalize_to_hlo_inc_gen tensorflow_mlir_hlo_hlo_ops_base_gen tensorflow_mlir_hlo_hlo_ops_gen tensorflow_mlir_hlo_hlo_ops_pattern_gen @@ -239,3 +240,18 @@ OUTS -gen-rewriters lib/Dialect/mhlo/transforms/generated_lower_complex.inc ) + +external_tablegen_library( + PACKAGE + tensorflow + NAME + mlir_hlo_chlo_legalize_to_hlo_inc_gen + TBLGEN + MLIR + ROOT + ${TF_MLIR_HLO_SRC_ROOT} + SRCS + "lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo_patterns.td" + OUTS + -gen-rewriters lib/Dialect/mhlo/transforms/generated_chlo_legalize_to_hlo.inc +)
diff --git a/docs/design_docs/metal_hal_driver.md b/docs/design_docs/metal_hal_driver.md index 5efb9d6..0729d9a 100644 --- a/docs/design_docs/metal_hal_driver.md +++ b/docs/design_docs/metal_hal_driver.md
@@ -130,10 +130,10 @@ At the moment the Metal HAL driver just has a very simple [`hal::Allocator`][hal-allocator] implementation. It just wraps a `MTLDevice` -and redirects all allocation requests to the `MTLDevice`. No page/pool/slab -or whatever. This is only meant to get started. In the future we should have -a better memory allocation library, probably by layering the [Vulkan -Memory Allocator][vma] on top of [`MTLHeap`][mtl-heap]. +and redirects all allocation requests to the `MTLDevice`. No page/pool/slab or +whatever. This is only meant to get started. In the future we should have a +better memory allocation library, probably by layering the +[Vulkan Memory Allocator][vma] on top of [`MTLHeap`][mtl-heap]. ### Buffer @@ -146,33 +146,32 @@ Metal provides four [`MTLStorageMode`][mtl-storage-mode] options: -* `MTLStorageModeShared`: The resource is stored in system memory and is - accessible to both the CPU and the GPU. -* `MTLStorageModeManaged`: The CPU and GPU may maintain separate copies of the - resource, and any changes must be explicitly synchronized. -* `MTLStorageModePrivate`: The resource can be accessed only by the GPU. -* `MTLStorageMemoryless`: The resource’s contents can be accessed only by the - GPU and only exist temporarily during a render pass. +* `MTLStorageModeShared`: The resource is stored in system memory and is + accessible to both the CPU and the GPU. +* `MTLStorageModeManaged`: The CPU and GPU may maintain separate copies of the + resource, and any changes must be explicitly synchronized. +* `MTLStorageModePrivate`: The resource can be accessed only by the GPU. +* `MTLStorageMemoryless`: The resource’s contents can be accessed only by the + GPU and only exist temporarily during a render pass. Among them, `MTLStorageModeManaged` is only available on macOS. IREE HAL defines serveral [`MemoryType`][hal-buffer]. They need to map to the above storage modes: -* If `kDeviceLocal` but not `kHostVisible`, `MTLStorageModePrivate` is chosen. -* If `kDeviceLocal` and `kHostVisible`: - * If macOS, `MTLStorageModeManaged` can be chosen. - * Otherwise, `MTLStorageModeShared` is chosen. -* If not `DeviceLocal` but `kDeviceVisible`, `MTLStorageModeShared` is chosen. -* If not `kDeviceLocal` and not `kDeviceVisible`, `MTLStorageModeShared` is - chosen. (TODO: We should probably use host buffer here.) +* If `kDeviceLocal` but not `kHostVisible`, `MTLStorageModePrivate` is chosen. +* If `kDeviceLocal` and `kHostVisible`: + * If macOS, `MTLStorageModeManaged` can be chosen. + * Otherwise, `MTLStorageModeShared` is chosen. +* If not `DeviceLocal` but `kDeviceVisible`, `MTLStorageModeShared` is chosen. +* If not `kDeviceLocal` and not `kDeviceVisible`, `MTLStorageModeShared` is + chosen. (TODO: We should probably use host buffer here.) IREE HAL also allows to create buffers with `kHostCoherent` bit. This may still be backed by `MTLStorageModeManaged` `MTLBuffer`s in macOS. To respect the `kHostCoherent` protocol, the Metal HAL driver will perform necessary `InValidate`/`Flush` operations automatically under the hood. - [macos-version-share]: https://gs.statcounter.com/macos-version-market-share/desktop/worldwide [ios-version-share]: https://developer.apple.com/support/app-store/ [iree-hal]: https://github.com/google/iree/tree/main/iree/hal
diff --git a/integrations/tensorflow/e2e/bool_test.py b/integrations/tensorflow/e2e/bool_test.py index 674657f..161f6ad 100644 --- a/integrations/tensorflow/e2e/bool_test.py +++ b/integrations/tensorflow/e2e/bool_test.py
@@ -39,6 +39,7 @@ @tf_test_utils.compile_module(MathModule) class BooleanTest(tf_test_utils.TracedModuleTestCase): + def test_constant(self): def constant(module):
diff --git a/third_party/llvm-project b/third_party/llvm-project index 009cd4e..7841e21 160000 --- a/third_party/llvm-project +++ b/third_party/llvm-project
@@ -1 +1 @@ -Subproject commit 009cd4e491033f57f547a7bda63e35b50a6e5cf7 +Subproject commit 7841e21c98495ba5e33e0d2507d985bd5b938445
diff --git a/third_party/tensorflow b/third_party/tensorflow index ef9971b..86b67b8 160000 --- a/third_party/tensorflow +++ b/third_party/tensorflow
@@ -1 +1 @@ -Subproject commit ef9971b6d7a1bba53a8d067c6fa092a998892b29 +Subproject commit 86b67b8c829a5a5c61af396ce20ae60e63d9514a