Skip to content

Files

Latest commit

fb32acb · Oct 31, 2024

History

History

objc

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Dec 30, 2020
Mar 18, 2024
Nov 24, 2020
Mar 18, 2024
Apr 12, 2022
Mar 27, 2024
Apr 18, 2024
Feb 8, 2023
Mar 21, 2024
Oct 31, 2024

TensorFlow Lite for Objective-C

TensorFlow Lite is TensorFlow's lightweight solution for Objective-C developers. It enables low-latency inference of on-device machine learning models with a small binary size and fast performance supporting hardware acceleration.

Build TensorFlow with iOS support

To build the Objective-C TensorFlow Lite library on Apple platforms, install from source or clone the GitHub repo. Then, configure TensorFlow by navigating to the root directory and executing the configure.py script:

python configure.py

Follow the prompts and when asked to build TensorFlow with iOS support, enter y.

CocoaPods developers

Add the TensorFlow Lite pod to your Podfile:

pod 'TensorFlowLiteObjC'

Then, run pod install.

In your Objective-C files, import the umbrella header:

#import "TFLTensorFlowLite.h"

Or, the module if you set CLANG_ENABLE_MODULES = YES in your Xcode project:

@import TFLTensorFlowLite;

Note: To import the TensorFlow Lite module in your Objective-C files, you must also include use_frameworks! in your Podfile.

Bazel developers

In your BUILD file, add the TensorFlowLite dependency to your target:

objc_library(
    deps=[
        "//tensorflow/lite/objc:TensorFlowLite",
    ],)

In your Objective-C files, import the umbrella header:

#import "TFLTensorFlowLite.h"

Or, the module if you set CLANG_ENABLE_MODULES = YES in your Xcode project:

@import TFLTensorFlowLite;

Build the TensorFlowLite Objective-C library target:

bazel build tensorflow/lite/objc:TensorFlowLite

Build the tests target:

bazel test tensorflow/lite/objc:tests

Generate the Xcode project using Tulsi

Open the //tensorflow/lite/objc/TensorFlowLite.tulsiproj using the TulsiApp or by running the generate_xcodeproj.sh script from the root tensorflow directory:

generate_xcodeproj.sh --genconfig tensorflow/lite/objc/TensorFlowLite.tulsiproj:TensorFlowLite --outputfolder ~/path/to/generated/TensorFlowLite.xcodeproj