STT-tensorflow/tensorflow/lite/experimental/swift
YoungSeok Yoon 772433a2a2 Add flag for using optimized TFLite CPU kernels on iOS
This adds new experimental flags to the interpreter options of TFLite Obj-C and
Swift APIs, which can be used for opting in to a set of highly optimized
floating point kernels provided via the XNNPACK delegate. The flags can be used
as follows.

Obj-C:

    TFLInterpreterOptions *options = [[TFLInterpreterOptions alloc] init];
    options.useXNNPACK = YES;
    NSError *error;
    TFLInterpreter *interpreter =
        [[TFLInterpreter alloc] initWithModelPath:@"model/path"
                                          options:options
                                            error:&error];

Swift:

    var options = InterpreterOptions()
    options.isXNNPackEnabled = true
    var interpreter = try Interpreter(modelPath: "model/path", options: options)

PiperOrigin-RevId: 317270012
Change-Id: I82aae43c3de13ab08af3c70513e2a458e807b0f1
2020-06-19 02:03:48 -07:00
..
Sources Add flag for using optimized TFLite CPU kernels on iOS 2020-06-19 02:03:48 -07:00
TensorFlowLite.tulsiproj Clean up the Swift TestApp and direct users to TFLite example apps. 2020-06-07 17:19:10 -07:00
TestApp Clean up the Swift TestApp and direct users to TFLite example apps. 2020-06-07 17:19:10 -07:00
Tests Add flag for using optimized TFLite CPU kernels on iOS 2020-06-19 02:03:48 -07:00
BUILD.apple Add build-related tags to TensorFlowLite and TensorFlowLiteAllDelegates 2020-06-08 21:45:02 -07:00
README.md Adds the TFLite version string to the Swift library. 2019-05-17 11:29:21 -07:00
TensorFlowLiteSwift-nightly.podspec Generate separate pod for Core ML delegate 2020-05-14 19:07:57 -07:00
TensorFlowLiteSwift.podspec Podspec updates for TFLite v2.2.0 2020-05-06 21:50:18 -07:00
TensorFlowLiteSwift.podspec.template Move test_spec in TensorFlowLiteSwift.podspec.template into subspec, so that the Delegate tests are only done in corresponding delegates. 2020-05-26 21:04:08 -07:00

TensorFlow Lite for Swift

TensorFlow Lite is TensorFlow's lightweight solution for Swift 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 Swift 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 'TensorFlowLiteSwift'

Then, run pod install.

In your Swift files, import the module:

import TensorFlowLite

Bazel developers

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

swift_library(
  deps = [
      "//tensorflow/lite/experimental/swift:TensorFlowLite",
  ],
)

In your Swift files, import the module:

import TensorFlowLite

Build the TensorFlowLite Swift library target:

bazel build tensorflow/lite/experimental/swift:TensorFlowLite

Build the Tests target:

bazel test tensorflow/lite/experimental/swift:Tests --swiftcopt=-enable-testing

Note: --swiftcopt=-enable-testing is required for optimized builds (-c opt).

Generate the Xcode project using Tulsi

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

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