mirror of
https://github.com/vee1e/tflite-micro.git
synced 2026-09-02 10:17:54 +00:00
To package the module `runtime` as `tflite_micro.runtime`, put `runtime` under a directory representing the Python namespace package `tflite_micro`. For organization's sake, move it all to the top-level directory `python/`. Adjust tests and docs to match. Some code outside of the Python extension module has come to depend on `python/tflite_micro:python_ops_resolver` as a replacement for `all_ops_resolver` (e.g.:`t/l/m/integration_tests/seanet/add/integration_tests.cc`). `python_ops_resolver` is intended to be a private implementation detail of the Python extension module. For now, grandfather in the dependent code by updating its references to the resolver's location; however, soon the dependent code should be migrated away to a different resolver. (#2033, https://issuetracker.google.com/286508251) BUG=part of #1484
97 lines
2.3 KiB
Text
97 lines
2.3 KiB
Text
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
|
|
load("@tflm_pip_deps//:requirements.bzl", "requirement")
|
|
load(
|
|
"//tensorflow/lite/micro:build_def.bzl",
|
|
"micro_copts",
|
|
)
|
|
load(
|
|
"//tensorflow:extra_rules.bzl",
|
|
"tflm_python_op_resolver_friends",
|
|
)
|
|
|
|
package(
|
|
features = ["-layering_check"],
|
|
licenses = ["notice"],
|
|
)
|
|
|
|
package_group(
|
|
name = "op_resolver_friends",
|
|
packages = tflm_python_op_resolver_friends(),
|
|
)
|
|
|
|
cc_library(
|
|
name = "python_ops_resolver",
|
|
srcs = [
|
|
"python_ops_resolver.cc",
|
|
],
|
|
hdrs = [
|
|
"python_ops_resolver.h",
|
|
],
|
|
copts = micro_copts(),
|
|
visibility = [
|
|
":op_resolver_friends",
|
|
"//tensorflow/lite/micro/integration_tests:__subpackages__",
|
|
"//tensorflow/lite/micro/python/interpreter/src:__subpackages__",
|
|
],
|
|
deps = [
|
|
"//tensorflow/lite/micro:micro_compatibility",
|
|
"//tensorflow/lite/micro:op_resolvers",
|
|
"//tensorflow/lite/micro/kernels:micro_ops",
|
|
],
|
|
)
|
|
|
|
pybind_extension(
|
|
name = "_runtime",
|
|
# target = _runtime.so because pybind_extension() appends suffix
|
|
srcs = [
|
|
"_runtime.cc",
|
|
"interpreter_wrapper.cc",
|
|
"interpreter_wrapper.h",
|
|
"numpy_utils.cc",
|
|
"numpy_utils.h",
|
|
"pybind11_lib.h",
|
|
"python_utils.cc",
|
|
"python_utils.h",
|
|
"shared_library.h",
|
|
],
|
|
deps = [
|
|
":python_ops_resolver",
|
|
"//tensorflow/lite/micro:micro_framework",
|
|
"//tensorflow/lite/micro:op_resolvers",
|
|
"//tensorflow/lite/micro:recording_allocators",
|
|
"@numpy_cc_deps//:cc_headers",
|
|
],
|
|
)
|
|
|
|
py_library(
|
|
name = "runtime",
|
|
srcs = [
|
|
"runtime.py",
|
|
],
|
|
data = [
|
|
":_runtime.so",
|
|
],
|
|
srcs_version = "PY3",
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
requirement("numpy"),
|
|
"//tensorflow/lite/tools:flatbuffer_utils",
|
|
],
|
|
)
|
|
|
|
py_test(
|
|
name = "runtime_test",
|
|
srcs = ["runtime_test.py"],
|
|
python_version = "PY3",
|
|
tags = [
|
|
"noasan",
|
|
"nomsan", # Python doesn't like these symbols in _runtime.so
|
|
"noubsan",
|
|
],
|
|
deps = [
|
|
requirement("numpy"),
|
|
requirement("tensorflow-cpu"),
|
|
":runtime",
|
|
"//tensorflow/lite/micro/testing:generate_test_models_lib",
|
|
],
|
|
)
|