From 94f5c126e73d7d1dc5ef5f14d855e25d5ed0140a Mon Sep 17 00:00:00 2001 From: YoungSeok Yoon Date: Sun, 7 Jun 2020 17:15:18 -0700 Subject: [PATCH] Clean up the Swift TestApp and direct users to TFLite example apps. PiperOrigin-RevId: 315192328 Change-Id: I5ae5c4bf3f6a14a08ba3f59431d5731b099a0f47 --- .../lite/experimental/swift/BUILD.apple | 33 +- .../Configs/TensorFlowLite.tulsigen | 68 ++-- .../lite/experimental/swift/TestApp/Podfile | 6 - .../lite/experimental/swift/TestApp/README.md | 7 + .../TestApp/TestApp.xcodeproj/project.pbxproj | 358 ------------------ .../swift/TestApp/TestApp/AppDelegate.swift | 20 - .../TestApp/Array+TensorFlowLite.swift | 39 -- .../AppIcon.appiconset/Contents.json | 98 ----- .../TestApp/Assets.xcassets/Contents.json | 6 - .../Base.lproj/LaunchScreen.storyboard | 43 --- .../TestApp/Base.lproj/Main.storyboard | 96 ----- .../TestApp/TestApp/Data+TensorFlowLite.swift | 27 -- .../swift/TestApp/TestApp/Info.plist | 46 --- .../TestApp/TestApp/ViewController.swift | 314 --------------- 14 files changed, 44 insertions(+), 1117 deletions(-) delete mode 100644 tensorflow/lite/experimental/swift/TestApp/Podfile create mode 100644 tensorflow/lite/experimental/swift/TestApp/README.md delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp.xcodeproj/project.pbxproj delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp/AppDelegate.swift delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp/Array+TensorFlowLite.swift delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp/Assets.xcassets/Contents.json delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp/Base.lproj/LaunchScreen.storyboard delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp/Base.lproj/Main.storyboard delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp/Data+TensorFlowLite.swift delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp/Info.plist delete mode 100644 tensorflow/lite/experimental/swift/TestApp/TestApp/ViewController.swift diff --git a/tensorflow/lite/experimental/swift/BUILD.apple b/tensorflow/lite/experimental/swift/BUILD.apple index 47bf9d3a626..9ea45854fed 100644 --- a/tensorflow/lite/experimental/swift/BUILD.apple +++ b/tensorflow/lite/experimental/swift/BUILD.apple @@ -2,7 +2,7 @@ load("//tensorflow/lite:special_rules.bzl", "ios_visibility_whitelist", "tflite_ios_lab_runner") load("//tensorflow/lite/experimental/ios:ios.bzl", "TFL_DEFAULT_TAGS", "TFL_DISABLED_SANITIZER_TAGS", "TFL_MINIMUM_OS_VERSION") -load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_static_framework", "ios_unit_test") +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_static_framework", "ios_unit_test") load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") package( @@ -125,37 +125,6 @@ swift_library( ], ) -ios_application( - name = "TestApp", - app_icons = glob(["TestApp/TestApp/Assets.xcassets/AppIcon.appiconset/**"]), - bundle_id = "com.tensorflow.lite.swift.TestApp", - families = [ - "ipad", - "iphone", - ], - infoplists = ["TestApp/TestApp/Info.plist"], - minimum_os_version = TFL_MINIMUM_OS_VERSION, - sdk_frameworks = [ - "CoreGraphics", - ], - tags = TFL_DEFAULT_TAGS, - deps = [ - ":TestAppLibrary", - ], -) - -swift_library( - name = "TestAppLibrary", - srcs = glob(["TestApp/TestApp/*.swift"]), - data = glob(["TestApp/TestApp/Base.lproj/*.storyboard"]), - module_name = "TestApp", - tags = TFL_DEFAULT_TAGS + ["manual"], - deps = [ - ":Resources", - ":TensorFlowLite", - ], -) - objc_library( name = "Resources", data = [ diff --git a/tensorflow/lite/experimental/swift/TensorFlowLite.tulsiproj/Configs/TensorFlowLite.tulsigen b/tensorflow/lite/experimental/swift/TensorFlowLite.tulsiproj/Configs/TensorFlowLite.tulsigen index d919ada871d..21e59a675bc 100644 --- a/tensorflow/lite/experimental/swift/TensorFlowLite.tulsiproj/Configs/TensorFlowLite.tulsigen +++ b/tensorflow/lite/experimental/swift/TensorFlowLite.tulsiproj/Configs/TensorFlowLite.tulsigen @@ -1,57 +1,61 @@ { - "sourceFilters" : [ - "tensorflow/lite/c", - "tensorflow/lite/experimental/swift", - "tensorflow/lite/experimental/swift/Sources", - "tensorflow/lite/experimental/swift/TestApp/TestApp", - "tensorflow/lite/experimental/swift/TestApp/TestApp/Base.lproj", - "tensorflow/lite/experimental/swift/Tests", + "additionalFilePaths" : [ + "tensorflow/lite/experimental/swift/BUILD" ], "buildTargets" : [ - "//tensorflow/lite/experimental/swift:TensorFlowLite", - "//tensorflow/lite/experimental/swift:TestApp", + "//tensorflow/lite/experimental/swift:TensorFlowLiteAllDelegates", "//tensorflow/lite/experimental/swift:Tests", + "//tensorflow/lite/experimental/swift:TestsLibrary" ], - "projectName" : "TensorFlowLite", "optionSet" : { - "LaunchActionPreActionScript" : { - "p" : "$(inherited)" - }, - "BazelBuildStartupOptionsRelease" : { + "BazelBuildOptionsDebug" : { "p" : "$(inherited)" }, "BazelBuildOptionsRelease" : { "p" : "$(inherited)" }, - "BazelBuildOptionsDebug" : { - "p" : "$(inherited)" - }, - "EnvironmentVariables" : { - "p" : "$(inherited)" - }, - "BuildActionPreActionScript" : { - "p" : "$(inherited)" - }, - "CommandlineArguments" : { - "p" : "$(inherited)" - }, - "TestActionPreActionScript" : { - "p" : "$(inherited)" - }, "BazelBuildStartupOptionsDebug" : { "p" : "$(inherited)" }, + "BazelBuildStartupOptionsRelease" : { + "p" : "$(inherited)" + }, "BuildActionPostActionScript" : { "p" : "$(inherited)" }, - "TestActionPostActionScript" : { + "BuildActionPreActionScript" : { + "p" : "$(inherited)" + }, + "CLANG_CXX_LANGUAGE_STANDARD" : { + "p" : "c++14" + }, + "CommandlineArguments" : { + "p" : "$(inherited)" + }, + "EnvironmentVariables" : { "p" : "$(inherited)" }, "LaunchActionPostActionScript" : { "p" : "$(inherited)" + }, + "LaunchActionPreActionScript" : { + "p" : "$(inherited)" + }, + "ProjectGenerationCompilationMode" : { + "p" : "opt" + }, + "TestActionPostActionScript" : { + "p" : "$(inherited)" + }, + "TestActionPreActionScript" : { + "p" : "$(inherited)" } }, - "additionalFilePaths" : [ - "tensorflow/lite/experimental/swift/BUILD" + "projectName" : "TensorFlowLite", + "sourceFilters" : [ + "tensorflow/lite/c", + "tensorflow/lite/experimental/swift", + "tensorflow/lite/experimental/swift/Sources", + "tensorflow/lite/experimental/swift/Tests" ] } diff --git a/tensorflow/lite/experimental/swift/TestApp/Podfile b/tensorflow/lite/experimental/swift/TestApp/Podfile deleted file mode 100644 index 2cd46d56689..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/Podfile +++ /dev/null @@ -1,6 +0,0 @@ -platform :ios, '9.0' - -target 'TestApp' do - use_frameworks! - pod 'TensorFlowLiteSwift' -end diff --git a/tensorflow/lite/experimental/swift/TestApp/README.md b/tensorflow/lite/experimental/swift/TestApp/README.md new file mode 100644 index 00000000000..7cd46132ac6 --- /dev/null +++ b/tensorflow/lite/experimental/swift/TestApp/README.md @@ -0,0 +1,7 @@ +# TensorFlow Lite Swift API Test App + +The TensorFlow Lite Swift API usage can be found in various iOS example apps +provided in the following locations. + +* [TensorFlow Lite example apps](https://www.tensorflow.org/lite/examples) +* [tensorflow/examples Repository](https://github.com/tensorflow/examples) diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp.xcodeproj/project.pbxproj b/tensorflow/lite/experimental/swift/TestApp/TestApp.xcodeproj/project.pbxproj deleted file mode 100644 index e6723e5a9a2..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp.xcodeproj/project.pbxproj +++ /dev/null @@ -1,358 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - 4A1E2BA0227C8B53006C23E2 /* multi_add.bin in Resources */ = {isa = PBXBuildFile; fileRef = 4A1E2B9D227C8B51006C23E2 /* multi_add.bin */; }; - 4A1E2BA1227C8B53006C23E2 /* add_quantized.bin in Resources */ = {isa = PBXBuildFile; fileRef = 4A1E2B9E227C8B52006C23E2 /* add_quantized.bin */; }; - 4A1E2BA2227C8B53006C23E2 /* add.bin in Resources */ = {isa = PBXBuildFile; fileRef = 4A1E2B9F227C8B52006C23E2 /* add.bin */; }; - 4A7304B421500B8400C90B21 /* Data+TensorFlowLite.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A7304B321500B8300C90B21 /* Data+TensorFlowLite.swift */; }; - 4AA72B732146ED64006C3AEF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA72B722146ED64006C3AEF /* AppDelegate.swift */; }; - 4AA72B752146ED64006C3AEF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA72B742146ED64006C3AEF /* ViewController.swift */; }; - 4AA72B782146ED64006C3AEF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4AA72B762146ED64006C3AEF /* Main.storyboard */; }; - 4AA72B7A2146ED66006C3AEF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4AA72B792146ED66006C3AEF /* Assets.xcassets */; }; - 4AA72B7D2146ED66006C3AEF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4AA72B7B2146ED66006C3AEF /* LaunchScreen.storyboard */; }; - 4ADDE0CE2176600E00FF07A2 /* Array+TensorFlowLite.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ADDE0CD2176600900FF07A2 /* Array+TensorFlowLite.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 4A1E2B9D227C8B51006C23E2 /* multi_add.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = multi_add.bin; path = ../../../../testdata/multi_add.bin; sourceTree = ""; }; - 4A1E2B9E227C8B52006C23E2 /* add_quantized.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = add_quantized.bin; path = ../../../../testdata/add_quantized.bin; sourceTree = ""; }; - 4A1E2B9F227C8B52006C23E2 /* add.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = add.bin; path = ../../../../testdata/add.bin; sourceTree = ""; }; - 4A7304B321500B8300C90B21 /* Data+TensorFlowLite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Data+TensorFlowLite.swift"; sourceTree = ""; }; - 4AA72B6F2146ED64006C3AEF /* TestApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4AA72B722146ED64006C3AEF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 4AA72B742146ED64006C3AEF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - 4AA72B772146ED64006C3AEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 4AA72B792146ED66006C3AEF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 4AA72B7C2146ED66006C3AEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 4AA72B7E2146ED66006C3AEF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 4ADDE0CD2176600900FF07A2 /* Array+TensorFlowLite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+TensorFlowLite.swift"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 4AA72B6C2146ED64006C3AEF /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 4AA72B662146ED64006C3AEF = { - isa = PBXGroup; - children = ( - 4AA72B712146ED64006C3AEF /* TestApp */, - 4AA72B702146ED64006C3AEF /* Products */, - ); - sourceTree = ""; - }; - 4AA72B702146ED64006C3AEF /* Products */ = { - isa = PBXGroup; - children = ( - 4AA72B6F2146ED64006C3AEF /* TestApp.app */, - ); - name = Products; - sourceTree = ""; - }; - 4AA72B712146ED64006C3AEF /* TestApp */ = { - isa = PBXGroup; - children = ( - 4AA72B722146ED64006C3AEF /* AppDelegate.swift */, - 4ADDE0CD2176600900FF07A2 /* Array+TensorFlowLite.swift */, - 4A7304B321500B8300C90B21 /* Data+TensorFlowLite.swift */, - 4AA72B742146ED64006C3AEF /* ViewController.swift */, - 4AA72B762146ED64006C3AEF /* Main.storyboard */, - 4AA72B792146ED66006C3AEF /* Assets.xcassets */, - 4AA72B7B2146ED66006C3AEF /* LaunchScreen.storyboard */, - 4AA72B7E2146ED66006C3AEF /* Info.plist */, - 4A1E2B9E227C8B52006C23E2 /* add_quantized.bin */, - 4A1E2B9F227C8B52006C23E2 /* add.bin */, - 4A1E2B9D227C8B51006C23E2 /* multi_add.bin */, - ); - path = TestApp; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 4AA72B6E2146ED64006C3AEF /* TestApp */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4AA72B812146ED66006C3AEF /* Build configuration list for PBXNativeTarget "TestApp" */; - buildPhases = ( - 4AA72B6B2146ED64006C3AEF /* Sources */, - 4AA72B6C2146ED64006C3AEF /* Frameworks */, - 4AA72B6D2146ED64006C3AEF /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = TestApp; - productName = TestApp; - productReference = 4AA72B6F2146ED64006C3AEF /* TestApp.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 4AA72B672146ED64006C3AEF /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 0940; - LastUpgradeCheck = 0940; - ORGANIZATIONNAME = Google; - TargetAttributes = { - 4AA72B6E2146ED64006C3AEF = { - CreatedOnToolsVersion = 9.4.1; - LastSwiftMigration = 1020; - }; - }; - }; - buildConfigurationList = 4AA72B6A2146ED64006C3AEF /* Build configuration list for PBXProject "TestApp" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 4AA72B662146ED64006C3AEF; - productRefGroup = 4AA72B702146ED64006C3AEF /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 4AA72B6E2146ED64006C3AEF /* TestApp */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 4AA72B6D2146ED64006C3AEF /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4A1E2BA1227C8B53006C23E2 /* add_quantized.bin in Resources */, - 4AA72B7D2146ED66006C3AEF /* LaunchScreen.storyboard in Resources */, - 4AA72B7A2146ED66006C3AEF /* Assets.xcassets in Resources */, - 4A1E2BA2227C8B53006C23E2 /* add.bin in Resources */, - 4AA72B782146ED64006C3AEF /* Main.storyboard in Resources */, - 4A1E2BA0227C8B53006C23E2 /* multi_add.bin in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 4AA72B6B2146ED64006C3AEF /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4AA72B732146ED64006C3AEF /* AppDelegate.swift in Sources */, - 4ADDE0CE2176600E00FF07A2 /* Array+TensorFlowLite.swift in Sources */, - 4A7304B421500B8400C90B21 /* Data+TensorFlowLite.swift in Sources */, - 4AA72B752146ED64006C3AEF /* ViewController.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 4AA72B762146ED64006C3AEF /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 4AA72B772146ED64006C3AEF /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - 4AA72B7B2146ED66006C3AEF /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 4AA72B7C2146ED66006C3AEF /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 4AA72B7F2146ED66006C3AEF /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.4; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 4AA72B802146ED66006C3AEF /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.4; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 4AA72B822146ED66006C3AEF /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - INFOPLIST_FILE = TestApp/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.tensorflow.lite.swift.TestApp; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 4AA72B832146ED66006C3AEF /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - INFOPLIST_FILE = TestApp/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.tensorflow.lite.swift.TestApp; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 4AA72B6A2146ED64006C3AEF /* Build configuration list for PBXProject "TestApp" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4AA72B7F2146ED66006C3AEF /* Debug */, - 4AA72B802146ED66006C3AEF /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4AA72B812146ED66006C3AEF /* Build configuration list for PBXNativeTarget "TestApp" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4AA72B822146ED66006C3AEF /* Debug */, - 4AA72B832146ED66006C3AEF /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 4AA72B672146ED64006C3AEF /* Project object */; -} diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp/AppDelegate.swift b/tensorflow/lite/experimental/swift/TestApp/TestApp/AppDelegate.swift deleted file mode 100644 index cc22043f7bb..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp/AppDelegate.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2019 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import UIKit - -@UIApplicationMain -final class AppDelegate: UIResponder, UIApplicationDelegate { - var window: UIWindow? -} diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp/Array+TensorFlowLite.swift b/tensorflow/lite/experimental/swift/TestApp/TestApp/Array+TensorFlowLite.swift deleted file mode 100644 index e2853e153eb..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp/Array+TensorFlowLite.swift +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2019 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import Foundation - -extension Array { - /// Creates a new array from the bytes of the given unsafe data. - /// - /// - Warning: The array's `Element` type must be trivial in that it can be copied bit for bit - /// with no indirection or reference-counting operations; otherwise, copying the raw bytes in - /// the `unsafeData`'s buffer to a new array returns an unsafe copy. - /// - Note: Returns `nil` if `unsafeData.count` is not a multiple of - /// `MemoryLayout.stride`. - /// - Parameter unsafeData: The data containing the bytes to turn into an array. - init?(unsafeData: Data) { - guard unsafeData.count % MemoryLayout.stride == 0 else { return nil } - #if swift(>=5.0) - self = unsafeData.withUnsafeBytes { .init($0.bindMemory(to: Element.self)) } - #else - self = unsafeData.withUnsafeBytes { - .init(UnsafeBufferPointer( - start: $0, - count: unsafeData.count / MemoryLayout.stride - )) - } - #endif // swift(>=5.0) - } -} diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/tensorflow/lite/experimental/swift/TestApp/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index d8db8d65fd7..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "83.5x83.5", - "scale" : "2x" - }, - { - "idiom" : "ios-marketing", - "size" : "1024x1024", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp/Assets.xcassets/Contents.json b/tensorflow/lite/experimental/swift/TestApp/TestApp/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c918..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp/Base.lproj/LaunchScreen.storyboard b/tensorflow/lite/experimental/swift/TestApp/TestApp/Base.lproj/LaunchScreen.storyboard deleted file mode 100644 index 83d172a2309..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp/Base.lproj/Main.storyboard b/tensorflow/lite/experimental/swift/TestApp/TestApp/Base.lproj/Main.storyboard deleted file mode 100644 index a93a4f0272e..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp/Base.lproj/Main.storyboard +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp/Data+TensorFlowLite.swift b/tensorflow/lite/experimental/swift/TestApp/TestApp/Data+TensorFlowLite.swift deleted file mode 100644 index 0a845f6b354..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp/Data+TensorFlowLite.swift +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2019 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import Foundation - -extension Data { - /// Creates a new buffer by copying the buffer pointer of the given array. - /// - /// - Warning: The given array's element type `T` must be trivial in that it can be copied bit - /// for bit with no indirection or reference-counting operations; otherwise, reinterpreting - /// data from the resulting buffer has undefined behavior. - /// - Parameter array: An array with elements of type `T`. - init(copyingBufferOf array: [T]) { - self = array.withUnsafeBufferPointer(Data.init) - } -} diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp/Info.plist b/tensorflow/lite/experimental/swift/TestApp/TestApp/Info.plist deleted file mode 100644 index 3ca3875f04e..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp/Info.plist +++ /dev/null @@ -1,46 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 0.0.1 - LSRequiresIPhoneOS - - NSCameraUsageDescription - NSCameraUsageDescription - NSPhotoLibraryUsageDescription - Select a photo to detect objects in. - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - - - diff --git a/tensorflow/lite/experimental/swift/TestApp/TestApp/ViewController.swift b/tensorflow/lite/experimental/swift/TestApp/TestApp/ViewController.swift deleted file mode 100644 index add37475156..00000000000 --- a/tensorflow/lite/experimental/swift/TestApp/TestApp/ViewController.swift +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright 2019 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import TensorFlowLite -import UIKit - -class ViewController: UIViewController { - - // MARK: - Properties - - /// TensorFlow Lite interpreter object for performing inference from a given model. - private var interpreter: Interpreter? - - /// Serial dispatch queue for managing `Interpreter` calls. - private let interpreterQueue = DispatchQueue( - label: Constant.dispatchQueueLabel, - qos: .userInitiated - ) - - /// The currently selected model. - private var currentModel: Model { - guard let currentModel = Model(rawValue: modelControl.selectedSegmentIndex) else { - preconditionFailure("Invalid model for selected segment index.") - } - return currentModel - } - - /// A description of the current model. - private var modelDescription: String { - guard let interpreter = interpreter else { return "" } - let inputCount = interpreter.inputTensorCount - let outputCount = interpreter.outputTensorCount - let inputTensors = (0.. String = { - guard let results = [Float32](unsafeData: outputTensor.data) else { return "No results." } - return resultsText + results.description - } - self.updateResultsText(results()) - } catch let error { - self.updateResultsText( - "Failed to invoke the interpreter with error: \(error.localizedDescription)" - ) - return - } - } - } - - private func invokeAddQuantized() { - interpreterQueue.async { - guard let interpreter = self.interpreter else { - self.updateResultsText(Constant.nilInterpreterErrorMessage) - return - } - do { - try interpreter.resizeInput(at: 0, to: [2]) - try interpreter.allocateTensors() - let input: [UInt8] = [1, 3] - let resultsText = self.modelDescription + "\n\n" + - "Performing 2 add operations on quantized input \(input.description) equals: " - self.updateResultsText(resultsText) - let data = Data(input) - try interpreter.copy(data, toInputAt: 0) - try interpreter.invoke() - let outputTensor = try interpreter.output(at: 0) - let results: () -> String = { - guard let quantizationParameters = outputTensor.quantizationParameters else { - return "No results." - } - let quantizedResults = [UInt8](outputTensor.data) - let dequantizedResults = quantizedResults.map { - quantizationParameters.scale * Float(Int($0) - quantizationParameters.zeroPoint) - } - return resultsText + quantizedResults.description + - ", dequantized results: " + dequantizedResults.description - } - self.updateResultsText(results()) - } catch let error { - self.updateResultsText( - "Failed to invoke the interpreter with error: \(error.localizedDescription)" - ) - return - } - } - } - - private func invokeMultiAdd() { - interpreterQueue.async { - guard let interpreter = self.interpreter else { - self.updateResultsText(Constant.nilInterpreterErrorMessage) - return - } - do { - let shape = Tensor.Shape(2) - try (0.. [Float32] in - let input = [Float32(index + 1), Float32(index + 2)] - let data = Data(copyingBufferOf: input) - try interpreter.copy(data, toInputAt: index) - return input - } - let resultsText = self.modelDescription + "\n\n" + - "Performing 3 add operations on inputs \(inputs.description) equals: " - self.updateResultsText(resultsText) - try interpreter.invoke() - let results = try (0.. [Float32] in - let tensor = try interpreter.output(at: index) - return [Float32](unsafeData: tensor.data) ?? [] - } - self.updateResultsText(resultsText + results.description) - } catch let error { - self.updateResultsText( - "Failed to invoke the interpreter with error: \(error.localizedDescription)" - ) - return - } - } - } - - private func updateResultsText(_ text: String? = nil) { - safeDispatchOnMain { self.resultsTextView.text = text } - } -} - -// MARK: - Constants - -private enum Constant { - static let dispatchQueueLabel = "TensorFlowLiteInterpreterQueue" - static let nilInterpreterErrorMessage = - "Failed to invoke the interpreter because the interpreter was nil." -} - -/// Models that can be loaded by the TensorFlow Lite `Interpreter`. -private enum Model: Int, CustomStringConvertible { - /// A float model that performs two add operations on one input tensor and returns the result in - /// one output tensor. - case add = 0 - /// A quantized model that performs two add operations on one input tensor and returns the result - /// in one output tensor. - case addQuantized = 1 - /// A float model that performs three add operations on four input tensors and returns the results - /// in 2 output tensors. - case multiAdd = 2 - - var fileInfo: (name: String, extension: String) { - switch self { - case .add: - return Add.fileInfo - case .addQuantized: - return AddQuantized.fileInfo - case .multiAdd: - return MultiAdd.fileInfo - } - } - - // MARK: - CustomStringConvertible - - var description: String { - switch self { - case .add: - return Add.name - case .addQuantized: - return AddQuantized.name - case .multiAdd: - return MultiAdd.name - } - } -} - -/// Values for the `Add` model. -private enum Add { - static let name = "Add" - static let fileInfo = (name: "add", extension: "bin") -} - -/// Values for the `AddQuantized` model. -private enum AddQuantized { - static let name = "AddQuantized" - static let fileInfo = (name: "add_quantized", extension: "bin") -} - -/// Values for the `MultiAdd` model. -private enum MultiAdd { - static let name = "MultiAdd" - static let fileInfo = (name: "multi_add", extension: "bin") -} - -// MARK: - Fileprivate - -/// Safely dispatches the given block on the main queue. If the current thread is `main`, the block -/// is executed synchronously; otherwise, the block is executed asynchronously on the main thread. -fileprivate func safeDispatchOnMain(_ block: @escaping () -> Void) { - if Thread.isMainThread { block(); return } - DispatchQueue.main.async { block() } -}