| # Copyright 2026 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 |
| |
| # bazel-to-cmake: skip |
| # Both files are written by hand |
| |
| load("@rules_python//python:defs.bzl", "py_library") |
| load("@rules_python//python:pip.bzl", "whl_filegroup") |
| load( |
| "//build_tools/bazel:build_defs.oss.bzl", |
| "iree_cc_library", |
| "iree_runtime_cc_binary", |
| "iree_runtime_cc_library", |
| ) |
| |
| package( |
| default_visibility = ["//visibility:public"], |
| features = ["layering_check"], |
| licenses = ["notice"], # Apache 2.0 |
| ) |
| |
| py_library( |
| name = "runtime_files", |
| srcs = glob(["iree/**/*.py"]), |
| ) |
| |
| exports_files(glob([ |
| "iree/**/*.py", |
| "iree/**/*.pyi", |
| ])) |
| |
| whl_filegroup( |
| name = "numpy_includes", |
| pattern = "numpy/_core/include/.*", |
| whl = "@pip//numpy:whl", |
| ) |
| |
| iree_cc_library( |
| name = "numpy_headers", |
| hdrs = [":numpy_includes"], |
| includes = ["numpy_includes/numpy/_core/include"], |
| visibility = ["//visibility:private"], |
| ) |
| |
| NANOBIND_COPTS = [ |
| "-fexceptions", |
| "-frtti", |
| ] |
| |
| NANOBIND_FEATURES = [ |
| "-use_header_modules", |
| ] |
| |
| iree_runtime_cc_library( |
| name = "bindings_python", |
| srcs = [ |
| "hal.cc", |
| "invoke.cc", |
| "io.cc", |
| "loop.cc", |
| "numpy_interop.cc", |
| "py_module.cc", |
| "status_utils.cc", |
| "tokenizer.cc", |
| "vm.cc", |
| ], |
| hdrs = [ |
| "binding.h", |
| "buffer_interop.h", |
| "hal.h", |
| "invoke.h", |
| "io.h", |
| "local_dlpack.h", |
| "loop.h", |
| "numpy_interop.h", |
| "py_module.h", |
| "status_utils.h", |
| "tokenizer.h", |
| "vm.h", |
| ], |
| copts = NANOBIND_COPTS, |
| features = NANOBIND_FEATURES, |
| deps = [ |
| ":numpy_headers", |
| "//runtime/src/iree/async", |
| "//runtime/src/iree/async/util:proactor_pool", |
| "//runtime/src/iree/base", |
| "//runtime/src/iree/base/internal:path", |
| "//runtime/src/iree/base/threading", |
| "//runtime/src/iree/base/tooling:flags", |
| "//runtime/src/iree/hal", |
| "//runtime/src/iree/hal/drivers", |
| "//runtime/src/iree/hal/utils:allocators", |
| "//runtime/src/iree/io:file_handle", |
| "//runtime/src/iree/io:parameter_index", |
| "//runtime/src/iree/io:parameter_index_provider", |
| "//runtime/src/iree/io:parameter_provider", |
| "//runtime/src/iree/io/formats:parser_registry", |
| "//runtime/src/iree/io/formats/irpa", |
| "//runtime/src/iree/modules/hal", |
| "//runtime/src/iree/modules/io/parameters", |
| "//runtime/src/iree/schemas:parameter_archive", |
| "//runtime/src/iree/tokenizer", |
| "//runtime/src/iree/tokenizer/format/huggingface:tokenizer_json", |
| "//runtime/src/iree/tokenizer/format/tiktoken", |
| "//runtime/src/iree/tokenizer/vocab", |
| "//runtime/src/iree/tooling:device_util", |
| "//runtime/src/iree/tooling/modules", |
| "//runtime/src/iree/vm", |
| "//runtime/src/iree/vm/bytecode:module", |
| "@nanobind", |
| "@rules_python//python/cc:current_py_cc_headers", |
| ], |
| ) |
| |
| iree_runtime_cc_binary( |
| name = "_runtime.so", |
| srcs = ["initialize_module.cc"], |
| copts = NANOBIND_COPTS, |
| features = NANOBIND_FEATURES, |
| linkopts = select({ |
| "@platforms//os:linux": ["-Wl,--export-dynamic"], |
| "//conditions:default": [], |
| }), |
| linkshared = 1, |
| linkstatic = 0, |
| deps = [ |
| ":bindings_python", |
| "//runtime/src/iree/base/tooling:flags", |
| "//runtime/src/iree/hal/drivers", |
| "@nanobind", |
| ], |
| ) |