From d8bf4acf4b7d4b72362972332debdcfce1c4682c Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Wed, 24 Jul 2024 12:27:38 -0700 Subject: [PATCH] Add `iree-c-embed-data` and `iree-flatcc-cli` to release packages. (#18001) Progress on https://github.com/iree-org/iree/issues/16203. First, this renames `generate_embed_data` to `iree-c-embed-data`. The name here dates back to having a single implementation shared across multiple projects using Bazel (and Google's internal Blaze). There isn't much code in the tool, but we've been using it for long enough to give it a name matching our other tools IMO. Next, this includes `iree-c-embed-data` and `iree-flatcc-cli` in the `iree-runtime` Python package (https://pypi.org/project/iree-runtime/). Both of these host tools are required for building large parts of the runtime (embed data for builtins and bitcode, flatcc for schemas), so including them in packages will allow users (and pkgci workflows) to get them without needing to build from source. --- build_tools/bazel/iree_bytecode_module.bzl | 4 ++-- .../bazel_to_cmake_converter.py | 4 +++- build_tools/cmake/iree_c_embed_data.cmake | 6 ++--- build_tools/embed_data/BUILD.bazel | 14 ++++++------ build_tools/embed_data/CMakeLists.txt | 22 +++++++++---------- build_tools/embed_data/build_defs.bzl | 4 ++-- ...data_main.cc => iree-c-embed-data-main.cc} | 0 ...data_test.cc => iree_c_embed_data_test.cc} | 0 build_tools/third_party/cuda/BUILD.template | 6 ++--- .../src/iree/compiler/Dialect/HAL/BUILD.bazel | 4 ++-- .../Dialect/Stream/Builtins/BUILD.bazel | 4 ++-- .../iree/compiler/Dialect/VMVX/BUILD.bazel | 4 ++-- .../iree/compiler/Modules/Check/BUILD.bazel | 4 ++-- .../compiler/Modules/HAL/Inline/BUILD.bazel | 4 ++-- .../compiler/Modules/HAL/Loader/BUILD.bazel | 4 ++-- .../Modules/IO/Parameters/BUILD.bazel | 4 ++-- .../web/sample_static/build_sample.sh | 2 +- experimental/webgpu/shaders/BUILD.bazel | 4 ++-- runtime/bindings/python/CMakeLists.txt | 16 ++++++++++++++ .../scripts/iree_c_embed_data/__main__.py | 21 ++++++++++++++++++ .../scripts/iree_flatcc_cli/__main__.py | 21 ++++++++++++++++++ runtime/setup.py | 4 ++++ runtime/src/iree/base/testing/BUILD.bazel | 4 ++-- runtime/src/iree/builtins/device/BUILD.bazel | 4 ++-- .../src/iree/builtins/musl/bin/BUILD.bazel | 4 ++-- runtime/src/iree/builtins/ukernel/BUILD.bazel | 4 ++-- .../hal/drivers/vulkan/builtin/BUILD.bazel | 4 ++-- .../iree/hal/local/elf/testdata/BUILD.bazel | 4 ++-- .../iree/io/formats/gguf/testdata/BUILD.bazel | 4 ++-- .../iree/io/formats/irpa/testdata/BUILD.bazel | 4 ++-- .../formats/safetensors/testdata/BUILD.bazel | 4 ++-- .../src/iree/tooling/testdata/npy/BUILD.bazel | 4 ++-- runtime/src/iree/vm/test/BUILD.bazel | 6 ++--- 33 files changed, 133 insertions(+), 69 deletions(-) rename build_tools/embed_data/{generate_embed_data_main.cc => iree-c-embed-data-main.cc} (100%) rename build_tools/embed_data/{c_embed_data_test.cc => iree_c_embed_data_test.cc} (100%) create mode 100644 runtime/bindings/python/iree/_runtime/scripts/iree_c_embed_data/__main__.py create mode 100644 runtime/bindings/python/iree/_runtime/scripts/iree_flatcc_cli/__main__.py diff --git a/build_tools/bazel/iree_bytecode_module.bzl b/build_tools/bazel/iree_bytecode_module.bzl index f0ab44061f0a..aa8985ea9bb0 100644 --- a/build_tools/bazel/iree_bytecode_module.bzl +++ b/build_tools/bazel/iree_bytecode_module.bzl @@ -6,7 +6,7 @@ """Rules for compiling IREE executables, modules, and archives.""" -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") # TODO(benvanik): port to a full starlark rule, document, etc. @@ -81,7 +81,7 @@ def iree_bytecode_module( # Embed the module for use in C. if c_identifier: - c_embed_data( + iree_c_embed_data( name = "%s_c" % (name), identifier = c_identifier, srcs = [module_name], diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py index 40c696bde0f3..9a1796b443fd 100644 --- a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py +++ b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py @@ -531,7 +531,7 @@ def cc_binary( f")\n\n" ) - def c_embed_data( + def iree_c_embed_data( self, name, srcs, @@ -555,6 +555,7 @@ def c_embed_data( "H_FILE_OUTPUT", h_file_output ) testonly_block = self._convert_option_block("TESTONLY", testonly) + strip_prefix_block = self._convert_option_block("STRIP_PREFIX", strip_prefix) identifier_block = self._convert_string_arg_block("IDENTIFIER", identifier) flatten_block = self._convert_option_block("FLATTEN", flatten) deps_block = self._convert_target_list_block("DEPS", deps) @@ -568,6 +569,7 @@ def c_embed_data( f"{h_file_output_block}" f"{identifier_block}" f"{testonly_block}" + f"{strip_prefix_block}" f"{flatten_block}" f" PUBLIC\n)\n\n" ) diff --git a/build_tools/cmake/iree_c_embed_data.cmake b/build_tools/cmake/iree_c_embed_data.cmake index 134bf2fc7ebd..07d07f1187ed 100644 --- a/build_tools/cmake/iree_c_embed_data.cmake +++ b/build_tools/cmake/iree_c_embed_data.cmake @@ -8,7 +8,7 @@ include(CMakeParseArguments) # iree_c_embed_data() # -# CMake function to imitate Bazel's c_embed_data rule. +# CMake function matching the iree_c_embed_data rule. # # Parameters: # PACKAGE: Name of the package (overrides actual path) @@ -96,8 +96,8 @@ function(iree_c_embed_data) add_custom_command( OUTPUT "${_RULE_H_FILE_OUTPUT}" "${_RULE_C_FILE_OUTPUT}" - COMMAND generate_embed_data ${_ARGS} ${_RESOLVED_SRCS} - DEPENDS generate_embed_data ${_RESOLVED_SRCS} + COMMAND iree-c-embed-data ${_ARGS} ${_RESOLVED_SRCS} + DEPENDS iree-c-embed-data ${_RESOLVED_SRCS} ) if(_RULE_TESTONLY) diff --git a/build_tools/embed_data/BUILD.bazel b/build_tools/embed_data/BUILD.bazel index 57b5597d88da..41bb4b9e13bf 100644 --- a/build_tools/embed_data/BUILD.bazel +++ b/build_tools/embed_data/BUILD.bazel @@ -6,7 +6,7 @@ # Generates source files with embedded file contents. -load(":build_defs.bzl", "c_embed_data") +load(":build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -15,11 +15,11 @@ package( ) cc_binary( - name = "generate_embed_data", - srcs = ["generate_embed_data_main.cc"], + name = "iree-c-embed-data", + srcs = ["iree-c-embed-data-main.cc"], ) -c_embed_data( +iree_c_embed_data( name = "testembed1", # do not sort srcs = [ @@ -31,7 +31,7 @@ c_embed_data( h_file_output = "testembed1.h", ) -c_embed_data( +iree_c_embed_data( name = "testembed2", srcs = [ "data/file3.bin", @@ -42,8 +42,8 @@ c_embed_data( ) cc_test( - name = "c_embed_data_test", - srcs = ["c_embed_data_test.cc"], + name = "iree_c_embed_data_test", + srcs = ["iree_c_embed_data_test.cc"], deps = [ ":testembed1", ":testembed2", diff --git a/build_tools/embed_data/CMakeLists.txt b/build_tools/embed_data/CMakeLists.txt index 0bdc616cfa95..074a06539842 100644 --- a/build_tools/embed_data/CMakeLists.txt +++ b/build_tools/embed_data/CMakeLists.txt @@ -6,23 +6,23 @@ # Just import if IREE_HOST_BIN_DIR is set (e.g. when cross-compiling). if(IREE_HOST_BIN_DIR) - iree_import_binary(NAME generate_embed_data) - install(IMPORTED_RUNTIME_ARTIFACTS generate_embed_data - COMPONENT generate_embed_data + iree_import_binary(NAME iree-c-embed-data) + install(IMPORTED_RUNTIME_ARTIFACTS iree-c-embed-data + COMPONENT iree-c-embed-data RUNTIME DESTINATION bin BUNDLE DESTINATION bin) return() endif() -add_executable(generate_embed_data) -target_sources(generate_embed_data PRIVATE generate_embed_data_main.cc) -set_target_properties(generate_embed_data PROPERTIES - OUTPUT_NAME generate_embed_data +add_executable(iree-c-embed-data) +target_sources(iree-c-embed-data PRIVATE iree-c-embed-data-main.cc) +set_target_properties(iree-c-embed-data PROPERTIES + OUTPUT_NAME iree-c-embed-data RUNTIME_OUTPUT_DIRECTORY "${IREE_BINARY_DIR}/tools" ) -install(TARGETS generate_embed_data - COMPONENT IREETools-CompilerExtra +install(TARGETS iree-c-embed-data + COMPONENT IREETools-Runtime RUNTIME DESTINATION bin BUNDLE DESTINATION bin) @@ -55,9 +55,9 @@ iree_c_embed_data( iree_cc_test( NAME - "c_embed_data_test" + "iree_c_embed_data_test" SRCS - "c_embed_data_test.cc" + "iree_c_embed_data_test.cc" DEPS ::testembed1 ::testembed2 diff --git a/build_tools/embed_data/build_defs.bzl b/build_tools/embed_data/build_defs.bzl index 30a67774c895..d0a03615d744 100644 --- a/build_tools/embed_data/build_defs.bzl +++ b/build_tools/embed_data/build_defs.bzl @@ -13,7 +13,7 @@ def clean_dep(dep): """ return str(Label(dep)) -def c_embed_data( +def iree_c_embed_data( name, srcs, c_file_output, @@ -22,7 +22,7 @@ def c_embed_data( strip_prefix = None, flatten = False, identifier = None, - generator = clean_dep("//build_tools/embed_data:generate_embed_data"), + generator = clean_dep("//build_tools/embed_data:iree-c-embed-data"), **kwargs): """Embeds 'srcs' into a C module. diff --git a/build_tools/embed_data/generate_embed_data_main.cc b/build_tools/embed_data/iree-c-embed-data-main.cc similarity index 100% rename from build_tools/embed_data/generate_embed_data_main.cc rename to build_tools/embed_data/iree-c-embed-data-main.cc diff --git a/build_tools/embed_data/c_embed_data_test.cc b/build_tools/embed_data/iree_c_embed_data_test.cc similarity index 100% rename from build_tools/embed_data/c_embed_data_test.cc rename to build_tools/embed_data/iree_c_embed_data_test.cc diff --git a/build_tools/third_party/cuda/BUILD.template b/build_tools/third_party/cuda/BUILD.template index cc863724bb68..c22a85030b5b 100644 --- a/build_tools/third_party/cuda/BUILD.template +++ b/build_tools/third_party/cuda/BUILD.template @@ -7,7 +7,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") # Variables and string substitutions don't work here because of course they don't -load("%IREE_REPO_ALIAS%//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("%IREE_REPO_ALIAS%//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package(default_visibility = ["//visibility:public"]) @@ -42,14 +42,14 @@ cc_library( includes = ["include"], ) -c_embed_data( +iree_c_embed_data( name = "libdevice_embedded", srcs = [ LIBDEVICE_REL_PATH, ], c_file_output = "iree_cuda/libdevice_embedded.c", flatten = True, - generator = "%IREE_REPO_ALIAS%//build_tools/embed_data:generate_embed_data", + generator = "%IREE_REPO_ALIAS%//build_tools/embed_data:iree-c-embed-data", h_file_output = "iree_cuda/libdevice_embedded.h", includes = [ "iree_cuda", diff --git a/compiler/src/iree/compiler/Dialect/HAL/BUILD.bazel b/compiler/src/iree/compiler/Dialect/HAL/BUILD.bazel index bf2e180ac3e7..c25e7def2093 100644 --- a/compiler/src/iree/compiler/Dialect/HAL/BUILD.bazel +++ b/compiler/src/iree/compiler/Dialect/HAL/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "hal_imports", srcs = ["hal.imports.mlir"], c_file_output = "hal.imports.c", diff --git a/compiler/src/iree/compiler/Dialect/Stream/Builtins/BUILD.bazel b/compiler/src/iree/compiler/Dialect/Stream/Builtins/BUILD.bazel index f832d0215ec8..96ab6117bdbb 100644 --- a/compiler/src/iree/compiler/Dialect/Stream/Builtins/BUILD.bazel +++ b/compiler/src/iree/compiler/Dialect/Stream/Builtins/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "Builtins", srcs = [ "fill_i16.mlir", diff --git a/compiler/src/iree/compiler/Dialect/VMVX/BUILD.bazel b/compiler/src/iree/compiler/Dialect/VMVX/BUILD.bazel index 106e509c8d19..cdbde6e02b52 100644 --- a/compiler/src/iree/compiler/Dialect/VMVX/BUILD.bazel +++ b/compiler/src/iree/compiler/Dialect/VMVX/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "vmvx_imports", srcs = ["vmvx.imports.mlir"], c_file_output = "vmvx.imports.c", diff --git a/compiler/src/iree/compiler/Modules/Check/BUILD.bazel b/compiler/src/iree/compiler/Modules/Check/BUILD.bazel index 1d5bfe4782fd..061d2591b563 100644 --- a/compiler/src/iree/compiler/Modules/Check/BUILD.bazel +++ b/compiler/src/iree/compiler/Modules/Check/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "check_imports", srcs = ["check.imports.mlir"], c_file_output = "check.imports.c", diff --git a/compiler/src/iree/compiler/Modules/HAL/Inline/BUILD.bazel b/compiler/src/iree/compiler/Modules/HAL/Inline/BUILD.bazel index 63eef0813738..a3be5dc62f1d 100644 --- a/compiler/src/iree/compiler/Modules/HAL/Inline/BUILD.bazel +++ b/compiler/src/iree/compiler/Modules/HAL/Inline/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "hal_inline_imports", srcs = ["hal_inline.imports.mlir"], c_file_output = "hal_inline.imports.c", diff --git a/compiler/src/iree/compiler/Modules/HAL/Loader/BUILD.bazel b/compiler/src/iree/compiler/Modules/HAL/Loader/BUILD.bazel index f7ac0a46bb13..8d7a5d5ff1ed 100644 --- a/compiler/src/iree/compiler/Modules/HAL/Loader/BUILD.bazel +++ b/compiler/src/iree/compiler/Modules/HAL/Loader/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "hal_loader_imports", srcs = ["hal_loader.imports.mlir"], c_file_output = "hal_loader.imports.c", diff --git a/compiler/src/iree/compiler/Modules/IO/Parameters/BUILD.bazel b/compiler/src/iree/compiler/Modules/IO/Parameters/BUILD.bazel index 40a4c177018c..e5e7cdc86d77 100644 --- a/compiler/src/iree/compiler/Modules/IO/Parameters/BUILD.bazel +++ b/compiler/src/iree/compiler/Modules/IO/Parameters/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "io_parameters_imports", srcs = ["io_parameters.imports.mlir"], c_file_output = "io_parameters.imports.c", diff --git a/experimental/web/sample_static/build_sample.sh b/experimental/web/sample_static/build_sample.sh index e8cddef1057a..78d120e022b8 100755 --- a/experimental/web/sample_static/build_sample.sh +++ b/experimental/web/sample_static/build_sample.sh @@ -57,7 +57,7 @@ mkdir -p "${BINARY_DIR}" ############################################################################### COMPILE_TOOL="${INSTALL_ROOT}/bin/iree-compile" -EMBED_DATA_TOOL="${INSTALL_ROOT}/bin/generate_embed_data" +EMBED_DATA_TOOL="${INSTALL_ROOT}/bin/iree-c-embed-data" INPUT_NAME="mnist" INPUT_PATH="${ROOT_DIR}/samples/models/mnist.mlir" diff --git a/experimental/webgpu/shaders/BUILD.bazel b/experimental/webgpu/shaders/BUILD.bazel index 9acb2393b6fe..bc6077eeda44 100644 --- a/experimental/webgpu/shaders/BUILD.bazel +++ b/experimental/webgpu/shaders/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "shaders", srcs = [ "fill_buffer.wgsl", diff --git a/runtime/bindings/python/CMakeLists.txt b/runtime/bindings/python/CMakeLists.txt index 29a3e5559f9e..ede73ab88dd0 100644 --- a/runtime/bindings/python/CMakeLists.txt +++ b/runtime/bindings/python/CMakeLists.txt @@ -143,17 +143,25 @@ iree_py_library( "iree/_runtime/libs.py" "iree/_runtime/scripts/iree_benchmark_executable/__main__.py" "iree/_runtime/scripts/iree_benchmark_module/__main__.py" + "iree/_runtime/scripts/iree_c_embed_data/__main__.py" "iree/_runtime/scripts/iree_cpuinfo/__main__.py" "iree/_runtime/scripts/iree_convert_parameters/__main__.py" "iree/_runtime/scripts/iree_create_parameters/__main__.py" "iree/_runtime/scripts/iree_dump_module/__main__.py" "iree/_runtime/scripts/iree_dump_parameters/__main__.py" + "iree/_runtime/scripts/iree_flatcc_cli/__main__.py" "iree/_runtime/scripts/iree_run_module/__main__.py" "iree/_runtime/scripts/iree_tracy_capture/__main__.py" PYEXT_DEPS iree_runtime_bindings_python_PyExtRt ) +iree_symlink_tool( + TARGET runtime + FROM_TOOL_TARGET iree-c-embed-data + TO_EXE_NAME iree/_runtime_libs/iree-c-embed-data +) + iree_symlink_tool( TARGET runtime FROM_TOOL_TARGET iree-benchmark-executable @@ -196,6 +204,12 @@ iree_symlink_tool( TO_EXE_NAME iree/_runtime_libs/iree-dump-parameters ) +iree_symlink_tool( + TARGET runtime + FROM_TOOL_TARGET iree-flatcc-cli + TO_EXE_NAME iree/_runtime_libs/iree-flatcc-cli +) + iree_symlink_tool( TARGET runtime FROM_TOOL_TARGET iree-run-module @@ -335,10 +349,12 @@ cmake_language(DEFER DIRECTORY \"${IREE_SOURCE_DIR}\" iree-cpuinfo iree-benchmark-executable iree-benchmark-module + iree-c-embed-data iree-convert-parameters iree-create-parameters iree-dump-module iree-dump-parameters + iree-flatcc-cli iree-run-module ${_EXTRA_INSTALL_TOOL_TARGETS} DESTINATION \"${_INSTALL_DIR}/iree/_runtime_libs\" diff --git a/runtime/bindings/python/iree/_runtime/scripts/iree_c_embed_data/__main__.py b/runtime/bindings/python/iree/_runtime/scripts/iree_c_embed_data/__main__.py new file mode 100644 index 000000000000..2e9f999741df --- /dev/null +++ b/runtime/bindings/python/iree/_runtime/scripts/iree_c_embed_data/__main__.py @@ -0,0 +1,21 @@ +# Copyright 2024 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 os +import subprocess +import sys +from ... import libs + + +def main(args=None): + if args is None: + args = sys.argv[1:] + exe = os.path.join(libs.library_path, "iree-c-embed-data") + return subprocess.call(args=[exe] + args) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/runtime/bindings/python/iree/_runtime/scripts/iree_flatcc_cli/__main__.py b/runtime/bindings/python/iree/_runtime/scripts/iree_flatcc_cli/__main__.py new file mode 100644 index 000000000000..a1f9005930be --- /dev/null +++ b/runtime/bindings/python/iree/_runtime/scripts/iree_flatcc_cli/__main__.py @@ -0,0 +1,21 @@ +# Copyright 2024 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 os +import subprocess +import sys +from ... import libs + + +def main(args=None): + if args is None: + args = sys.argv[1:] + exe = os.path.join(libs.library_path, "iree-flatcc-cli") + return subprocess.call(args=[exe] + args) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/runtime/setup.py b/runtime/setup.py index 8150485c7b4e..0dc33d587dc9 100644 --- a/runtime/setup.py +++ b/runtime/setup.py @@ -575,11 +575,13 @@ def populate_built_package(abs_dir): "iree-benchmark-executable*", "iree-benchmark-module*", # These utilities are invariant wrt tracing and are only built for the default runtime. + "iree-c-embed-data*", "iree-create-parameters*", "iree-convert-parameters*", "iree-dump-module*", "iree-dump-parameters*", "iree-cpuinfo*", + "iree-flatcc-cli*", ], }, ( @@ -601,11 +603,13 @@ def populate_built_package(abs_dir): "iree-run-module = iree._runtime.scripts.iree_run_module.__main__:main", "iree-benchmark-executable = iree._runtime.scripts.iree_benchmark_executable.__main__:main", "iree-benchmark-module = iree._runtime.scripts.iree_benchmark_module.__main__:main", + "iree-c-embed-data = iree._runtime.scripts.iree_c_embed_data.__main__:main", "iree-create-parameters = iree._runtime.scripts.iree_create_parameters.__main__:main", "iree-convert-parameters = iree._runtime.scripts.iree_convert_parameters.__main__:main", "iree-dump-module = iree._runtime.scripts.iree_dump_module.__main__:main", "iree-dump-parameters = iree._runtime.scripts.iree_dump_parameters.__main__:main", "iree-cpuinfo = iree._runtime.scripts.iree_cpuinfo.__main__:main", + "iree-flatcc-cli = iree._runtime.scripts.iree_flatcc_cli.__main__:main", ] + ( [ diff --git a/runtime/src/iree/base/testing/BUILD.bazel b/runtime/src/iree/base/testing/BUILD.bazel index 19dffda94e0f..43a182fe6fbc 100644 --- a/runtime/src/iree/base/testing/BUILD.bazel +++ b/runtime/src/iree/base/testing/BUILD.bazel @@ -5,7 +5,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("//build_tools/bazel:build_defs.oss.bzl", "iree_runtime_cc_binary", "iree_runtime_cc_test") -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( features = ["layering_check"], @@ -19,7 +19,7 @@ iree_runtime_cc_binary( linkshared = True, ) -c_embed_data( +iree_c_embed_data( name = "dynamic_library_test_library", testonly = True, srcs = [":dynamic_library_test_library.so"], diff --git a/runtime/src/iree/builtins/device/BUILD.bazel b/runtime/src/iree/builtins/device/BUILD.bazel index 7a29094cb617..ff3c933e5e32 100644 --- a/runtime/src/iree/builtins/device/BUILD.bazel +++ b/runtime/src/iree/builtins/device/BUILD.bazel @@ -6,7 +6,7 @@ load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content", "iree_runtime_cc_library") load("//build_tools/bazel:iree_bitcode_library.bzl", "iree_bitcode_library") -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -72,7 +72,7 @@ iree_bitcode_library( internal_hdrs = BITCODE_HDRS, ) -c_embed_data( +iree_c_embed_data( name = "libdevice_bitcode", srcs = [ ":libdevice_aarch64_sme.bc", diff --git a/runtime/src/iree/builtins/musl/bin/BUILD.bazel b/runtime/src/iree/builtins/musl/bin/BUILD.bazel index d9a2529f1dfc..90da83a34514 100644 --- a/runtime/src/iree/builtins/musl/bin/BUILD.bazel +++ b/runtime/src/iree/builtins/musl/bin/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "libmusl", srcs = [ "libmusl_wasm32_generic.bc", diff --git a/runtime/src/iree/builtins/ukernel/BUILD.bazel b/runtime/src/iree/builtins/ukernel/BUILD.bazel index f07930c998be..774eeaec3696 100644 --- a/runtime/src/iree/builtins/ukernel/BUILD.bazel +++ b/runtime/src/iree/builtins/ukernel/BUILD.bazel @@ -6,7 +6,7 @@ load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content", "iree_runtime_cc_library") load("//build_tools/bazel:iree_bitcode_library.bzl", "iree_bitcode_library", "iree_link_bitcode") -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -134,7 +134,7 @@ bitcode_specific_archs = [ ] if arch in bitcode_specific_archs else []), ) for arch in bitcode_generic_archs] -c_embed_data( +iree_c_embed_data( name = "embed_ukernel_bitcode", srcs = [ ":ukernel_bitcode_%s.bc" % arch diff --git a/runtime/src/iree/hal/drivers/vulkan/builtin/BUILD.bazel b/runtime/src/iree/hal/drivers/vulkan/builtin/BUILD.bazel index 083e92f188db..8d4e7f3650f4 100644 --- a/runtime/src/iree/hal/drivers/vulkan/builtin/BUILD.bazel +++ b/runtime/src/iree/hal/drivers/vulkan/builtin/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "builtin", srcs = [ "fill_unaligned.spv", diff --git a/runtime/src/iree/hal/local/elf/testdata/BUILD.bazel b/runtime/src/iree/hal/local/elf/testdata/BUILD.bazel index 40f01247f600..7791a8ecb964 100644 --- a/runtime/src/iree/hal/local/elf/testdata/BUILD.bazel +++ b/runtime/src/iree/hal/local/elf/testdata/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "elementwise_mul", srcs = glob(["elementwise_mul_*.so"]), c_file_output = "elementwise_mul.c", diff --git a/runtime/src/iree/io/formats/gguf/testdata/BUILD.bazel b/runtime/src/iree/io/formats/gguf/testdata/BUILD.bazel index 9777a9cad540..c0b335fce620 100644 --- a/runtime/src/iree/io/formats/gguf/testdata/BUILD.bazel +++ b/runtime/src/iree/io/formats/gguf/testdata/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "gguf_files", testonly = True, srcs = [ diff --git a/runtime/src/iree/io/formats/irpa/testdata/BUILD.bazel b/runtime/src/iree/io/formats/irpa/testdata/BUILD.bazel index 2a5f86ea7d51..b558f37ea553 100644 --- a/runtime/src/iree/io/formats/irpa/testdata/BUILD.bazel +++ b/runtime/src/iree/io/formats/irpa/testdata/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "irpa_files", testonly = True, srcs = glob(["*.irpa"]), diff --git a/runtime/src/iree/io/formats/safetensors/testdata/BUILD.bazel b/runtime/src/iree/io/formats/safetensors/testdata/BUILD.bazel index 75e2fd62199b..1b30fdf06461 100644 --- a/runtime/src/iree/io/formats/safetensors/testdata/BUILD.bazel +++ b/runtime/src/iree/io/formats/safetensors/testdata/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "safetensors_files", testonly = True, srcs = [ diff --git a/runtime/src/iree/tooling/testdata/npy/BUILD.bazel b/runtime/src/iree/tooling/testdata/npy/BUILD.bazel index 37a5c2f4251e..fdd5ddabb6ab 100644 --- a/runtime/src/iree/tooling/testdata/npy/BUILD.bazel +++ b/runtime/src/iree/tooling/testdata/npy/BUILD.bazel @@ -4,7 +4,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//visibility:public"], @@ -12,7 +12,7 @@ package( licenses = ["notice"], # Apache 2.0 ) -c_embed_data( +iree_c_embed_data( name = "npy", testonly = True, srcs = [ diff --git a/runtime/src/iree/vm/test/BUILD.bazel b/runtime/src/iree/vm/test/BUILD.bazel index 033da5e54ceb..caa1cff87663 100644 --- a/runtime/src/iree/vm/test/BUILD.bazel +++ b/runtime/src/iree/vm/test/BUILD.bazel @@ -6,7 +6,7 @@ load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content") load("//build_tools/bazel:iree_bytecode_module.bzl", "iree_bytecode_module") -load("//build_tools/embed_data:build_defs.bzl", "c_embed_data") +load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") package( default_visibility = ["//runtime/src/iree/vm:__subpackages__"], @@ -23,7 +23,7 @@ endif() inline = True, ) -c_embed_data( +iree_c_embed_data( name = "all_bytecode_modules_c", srcs = [ ":arithmetic_ops.vmfb", @@ -303,7 +303,7 @@ iree_bytecode_module( ], ) -c_embed_data( +iree_c_embed_data( name = "async_bytecode_modules_c", srcs = [ ":async_ops.vmfb",