Make the TFLite with select TF ops for iOS composable
PiperOrigin-RevId: 283472625 Change-Id: I59b4c378465043c5dfbb61e454073afadade2ac1
This commit is contained in:
parent
1c03f956c5
commit
05ed82f0f4
.bazelrc
tensorflow/lite/experimental/ios
3
.bazelrc
3
.bazelrc
@ -100,9 +100,9 @@ build --apple_platform_type=macos
|
||||
# iOS configs for each architecture and the fat binary builds.
|
||||
build:ios --apple_platform_type=ios
|
||||
build:ios --apple_bitcode=embedded --copt=-fembed-bitcode
|
||||
build:ios --copt=-Wno-c++11-narrowing
|
||||
build:ios_armv7 --config=ios
|
||||
build:ios_armv7 --cpu=ios_armv7
|
||||
build:ios_armv7 --copt -Wno-c++11-narrowing
|
||||
build:ios_arm64 --config=ios
|
||||
build:ios_arm64 --cpu=ios_arm64
|
||||
build:ios_i386 --config=ios
|
||||
@ -111,7 +111,6 @@ build:ios_x86_64 --config=ios
|
||||
build:ios_x86_64 --cpu=ios_x86_64
|
||||
build:ios_fat --config=ios
|
||||
build:ios_fat --ios_multi_cpus=armv7,arm64,i386,x86_64
|
||||
build:ios_fat --copt -Wno-c++11-narrowing
|
||||
|
||||
# Config to use a mostly-static build and disable modular op registration
|
||||
# support (this will revert to loading TensorFlow with RTLD_GLOBAL in Python).
|
||||
|
@ -26,18 +26,6 @@ ios_static_framework(
|
||||
],
|
||||
)
|
||||
|
||||
# bazel build -c opt --config=ios --ios_multi_cpus=armv7,arm64,x86_64 //tensorflow/lite/experimental/ios:TensorFlowLiteCWithSelectTfOps_framework
|
||||
ios_static_framework(
|
||||
name = "TensorFlowLiteCWithSelectTfOps_framework",
|
||||
hdrs = TFL_LIBRARY_HDRS,
|
||||
bundle_name = "TensorFlowLiteC",
|
||||
minimum_os_version = TFL_MINIMUM_OS_VERSION,
|
||||
deps = [
|
||||
":TensorFlowLiteC",
|
||||
"//tensorflow/lite/delegates/flex:delegate",
|
||||
],
|
||||
)
|
||||
|
||||
objc_library(
|
||||
name = "TensorFlowLiteC",
|
||||
hdrs = TFL_LIBRARY_HDRS,
|
||||
@ -50,6 +38,24 @@ objc_library(
|
||||
],
|
||||
)
|
||||
|
||||
# This target builds the flex delegate as a separate static framework, which
|
||||
# does not include the TensorFlow Lite runtime. As this target does not contain
|
||||
# TensorFlow Lite runtime, it is intended to be linked along with the
|
||||
# TensorFlowLiteC framework above in a composable way.
|
||||
#
|
||||
# The flex delegate cannot be built for i386, so it can't be built with ios_fat
|
||||
# config.
|
||||
#
|
||||
# bazel build -c opt --config=ios --ios_multi_cpus=armv7,arm64,x86_64 //tensorflow/lite/experimental/ios:TensorFlowLiteSelectTfOps_framework
|
||||
ios_static_framework(
|
||||
name = "TensorFlowLiteSelectTfOps_framework",
|
||||
bundle_name = "TensorFlowLiteSelectTfOps",
|
||||
minimum_os_version = TFL_MINIMUM_OS_VERSION,
|
||||
deps = [
|
||||
"//tensorflow/lite/delegates/flex:delegate",
|
||||
],
|
||||
)
|
||||
|
||||
# Using this intermediate target is a workaround for a bug in bazel build rules
|
||||
# involving mixed objc_library & cc_library deps mentioned in (b/74809458).
|
||||
# When these dependencies are declared directly under the "TensorFlowLiteC"
|
||||
@ -79,6 +85,6 @@ build_test(
|
||||
],
|
||||
targets = [
|
||||
":TensorFlowLiteC_framework",
|
||||
":TensorFlowLiteCWithSelectTfOps_framework",
|
||||
":TensorFlowLiteSelectTfOps_framework",
|
||||
],
|
||||
)
|
||||
|
@ -0,0 +1,19 @@
|
||||
# TensorFlow Lite with Select TensorFlow ops
|
||||
|
||||
For enabling the Select TensorFlow ops for your TensorFlow Lite app, please add
|
||||
the `TensorFlowLiteSelectTfOps` pod to your Podfile, in addition to
|
||||
`TensorFlowLiteSwift` or `TensorFlowLiteObjC` pod, depending on your primary
|
||||
language.
|
||||
|
||||
After that, you should also force load the framework from your project. Add the
|
||||
following line to the `Other Linker Flags` under your project's Build Settings
|
||||
page.
|
||||
|
||||
```
|
||||
-force_load "$(PROJECT_DIR)/Pods/TensorFlowLiteSelectTfOps/Frameworks/TensorFlowLiteSelectTfOps.framework/TensorFlowLiteSelectTfOps"
|
||||
```
|
||||
|
||||
Please refer to the [Select operators from TensorFlow][ops-select] guide for
|
||||
more details.
|
||||
|
||||
[ops-select]: https://www.tensorflow.org/lite/guide/ops_select#ios
|
@ -0,0 +1,21 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'TensorFlowLiteSelectTfOps'
|
||||
s.version = '${TFL_BUILD_VERSION}'
|
||||
s.authors = 'Google Inc.'
|
||||
s.license = { :type => 'Apache' }
|
||||
s.homepage = 'https://github.com/tensorflow/tensorflow'
|
||||
s.source = { :http => "${TFL_DOWNLOAD_URL}" }
|
||||
s.summary = 'TensorFlow Lite'
|
||||
s.description = <<-DESC
|
||||
|
||||
This pod can be used in addition to `TensorFlowLiteSwift` or
|
||||
`TensorFlowLiteObjC` pod, in order to enable Select TensorFlow ops. The
|
||||
resulting binary should also be force-loaded to the final app binary.
|
||||
DESC
|
||||
|
||||
s.ios.deployment_target = '9.0'
|
||||
|
||||
s.module_name = 'TensorFlowLiteSelectTfOps'
|
||||
s.library = 'c++'
|
||||
s.vendored_frameworks = 'Frameworks/TensorFlowLiteSelectTfOps.framework'
|
||||
end
|
Loading…
Reference in New Issue
Block a user