Clean up the Swift TestApp and direct users to TFLite example apps.
PiperOrigin-RevId: 315192328 Change-Id: I5ae5c4bf3f6a14a08ba3f59431d5731b099a0f47
This commit is contained in:
parent
a646c1280d
commit
94f5c126e7
@ -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 = [
|
||||
|
@ -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"
|
||||
]
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
platform :ios, '9.0'
|
||||
|
||||
target 'TestApp' do
|
||||
use_frameworks!
|
||||
pod 'TensorFlowLiteSwift'
|
||||
end
|
7
tensorflow/lite/experimental/swift/TestApp/README.md
Normal file
7
tensorflow/lite/experimental/swift/TestApp/README.md
Normal file
@ -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)
|
@ -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 = "<group>"; };
|
||||
4A1E2B9E227C8B52006C23E2 /* add_quantized.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = add_quantized.bin; path = ../../../../testdata/add_quantized.bin; sourceTree = "<group>"; };
|
||||
4A1E2B9F227C8B52006C23E2 /* add.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = add.bin; path = ../../../../testdata/add.bin; sourceTree = "<group>"; };
|
||||
4A7304B321500B8300C90B21 /* Data+TensorFlowLite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Data+TensorFlowLite.swift"; sourceTree = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
4AA72B742146ED64006C3AEF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
4AA72B772146ED64006C3AEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
4AA72B792146ED66006C3AEF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
4AA72B7C2146ED66006C3AEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
4AA72B7E2146ED66006C3AEF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
4ADDE0CD2176600900FF07A2 /* Array+TensorFlowLite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+TensorFlowLite.swift"; sourceTree = "<group>"; };
|
||||
/* 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 = "<group>";
|
||||
};
|
||||
4AA72B702146ED64006C3AEF /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4AA72B6F2146ED64006C3AEF /* TestApp.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
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 = "<group>";
|
||||
};
|
||||
/* 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 = "<group>";
|
||||
};
|
||||
4AA72B7B2146ED66006C3AEF /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
4AA72B7C2146ED66006C3AEF /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* 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 */;
|
||||
}
|
@ -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?
|
||||
}
|
@ -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<Element>.stride`.
|
||||
/// - Parameter unsafeData: The data containing the bytes to turn into an array.
|
||||
init?(unsafeData: Data) {
|
||||
guard unsafeData.count % MemoryLayout<Element>.stride == 0 else { return nil }
|
||||
#if swift(>=5.0)
|
||||
self = unsafeData.withUnsafeBytes { .init($0.bindMemory(to: Element.self)) }
|
||||
#else
|
||||
self = unsafeData.withUnsafeBytes {
|
||||
.init(UnsafeBufferPointer<Element>(
|
||||
start: $0,
|
||||
count: unsafeData.count / MemoryLayout<Element>.stride
|
||||
))
|
||||
}
|
||||
#endif // swift(>=5.0)
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TensorFlow Lite" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Gq-PV-hia">
|
||||
<rect key="frame" x="16" y="314" width="343" height="39"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="32"/>
|
||||
<color key="textColor" red="1" green="0.43529411764705883" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="3Gq-PV-hia" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="16" id="aXL-9T-5Pf"/>
|
||||
<constraint firstItem="3Gq-PV-hia" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="cDf-Go-1FR"/>
|
||||
<constraint firstAttribute="trailing" secondItem="3Gq-PV-hia" secondAttribute="trailing" constant="16" id="fB9-BX-A3B"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="52" y="374.66266866566718"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
@ -1,96 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="tne-QT-ifu">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="viewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="BYZ-38-t0r" customClass="ViewController" customModule="TestApp" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Mj-sL-hrd">
|
||||
<rect key="frame" x="0.0" y="367" width="375" height="300"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="300" id="YUb-MC-D5w"/>
|
||||
</constraints>
|
||||
<color key="textColor" cocoaTouchSystemColor="tableCellGroupedBackgroundColor"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
</textView>
|
||||
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Qwg-EP-bd6" userLabel="Bottom Toolbar">
|
||||
<rect key="frame" x="0.0" y="323" width="375" height="44"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="44" id="jhT-Q0-E9N"/>
|
||||
</constraints>
|
||||
<items>
|
||||
<barButtonItem style="plain" systemItem="flexibleSpace" id="P3q-uA-YUa"/>
|
||||
<barButtonItem title="Invoke Interpreter" id="A4J-Mg-nmd" userLabel="Invoke Button">
|
||||
<connections>
|
||||
<action selector="invokeInterpreter:" destination="BYZ-38-t0r" id="lZU-x7-PsJ"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<barButtonItem style="plain" systemItem="flexibleSpace" id="Qad-Pa-ySg"/>
|
||||
</items>
|
||||
</toolbar>
|
||||
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Gkb-TR-PCB" userLabel="Top Toolbar">
|
||||
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="44" id="hSD-2q-fUE"/>
|
||||
</constraints>
|
||||
<items>
|
||||
<barButtonItem style="plain" id="LKw-TX-bbH">
|
||||
<segmentedControl key="customView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="bar" selectedSegmentIndex="0" id="rhA-nW-xzT">
|
||||
<rect key="frame" x="16" y="7" width="343" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<segments>
|
||||
<segment title="Add"/>
|
||||
<segment title="AddQuantized"/>
|
||||
<segment title="MultiAdd"/>
|
||||
</segments>
|
||||
<connections>
|
||||
<action selector="modelChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="YnG-Ov-B5D"/>
|
||||
</connections>
|
||||
</segmentedControl>
|
||||
</barButtonItem>
|
||||
</items>
|
||||
</toolbar>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="Gkb-TR-PCB" secondAttribute="trailing" id="4Cr-Sf-I7n"/>
|
||||
<constraint firstItem="7Mj-sL-hrd" firstAttribute="bottom" secondItem="wfy-db-euE" secondAttribute="top" id="6ot-zD-sze"/>
|
||||
<constraint firstItem="7Mj-sL-hrd" firstAttribute="top" secondItem="Qwg-EP-bd6" secondAttribute="bottom" id="ELA-C6-NiG"/>
|
||||
<constraint firstAttribute="trailing" secondItem="7Mj-sL-hrd" secondAttribute="trailing" id="HDO-xr-mBl"/>
|
||||
<constraint firstItem="Gkb-TR-PCB" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="Kmo-6K-gS4"/>
|
||||
<constraint firstItem="Qwg-EP-bd6" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="hGu-lm-fMG"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Qwg-EP-bd6" secondAttribute="trailing" id="iXR-LK-nTO"/>
|
||||
<constraint firstItem="7Mj-sL-hrd" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="nr7-jW-ZYf"/>
|
||||
<constraint firstItem="Gkb-TR-PCB" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="8" id="uCF-VW-rR0"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="invokeButton" destination="A4J-Mg-nmd" id="UxZ-Ft-E45"/>
|
||||
<outlet property="modelControl" destination="rhA-nW-xzT" id="KKf-TT-BQ2"/>
|
||||
<outlet property="resultsTextView" destination="7Mj-sL-hrd" id="T4I-z4-tYA"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="125.59999999999999" y="133.5832083958021"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
@ -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<T>(copyingBufferOf array: [T]) {
|
||||
self = array.withUnsafeBufferPointer(Data.init)
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.0.1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>NSCameraUsageDescription</string>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>Select a photo to detect objects in.</string>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
@ -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..<inputCount).map { index in
|
||||
var tensorInfo = " Input \(index + 1): "
|
||||
do {
|
||||
let tensor = try interpreter.input(at: index)
|
||||
tensorInfo += "\(tensor)"
|
||||
} catch let error {
|
||||
tensorInfo += "\(error.localizedDescription)"
|
||||
}
|
||||
return tensorInfo
|
||||
}.joined(separator: "\n")
|
||||
let outputTensors = (0..<outputCount).map { index in
|
||||
var tensorInfo = " Output \(index + 1): "
|
||||
do {
|
||||
let tensor = try interpreter.output(at: index)
|
||||
tensorInfo += "\(tensor)"
|
||||
} catch let error {
|
||||
tensorInfo += "\(error.localizedDescription)"
|
||||
}
|
||||
return tensorInfo
|
||||
}.joined(separator: "\n")
|
||||
return "Model Description:\n" +
|
||||
" Input Tensor Count = \(inputCount)\n\(inputTensors)\n\n" +
|
||||
" Output Tensor Count = \(outputCount)\n\(outputTensors)"
|
||||
}
|
||||
|
||||
// MARK: - IBOutlets
|
||||
|
||||
/// A segmented control for changing models. See the `Model` enum for available models.
|
||||
@IBOutlet private var modelControl: UISegmentedControl!
|
||||
|
||||
@IBOutlet private var resultsTextView: UITextView!
|
||||
@IBOutlet private var invokeButton: UIBarButtonItem!
|
||||
|
||||
// MARK: - UIViewController
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
invokeButton.isEnabled = false
|
||||
updateResultsText("Using TensorFlow Lite runtime version \(TensorFlowLite.Runtime.version).")
|
||||
loadModel()
|
||||
}
|
||||
|
||||
// MARK: - IBActions
|
||||
|
||||
@IBAction func modelChanged(_ sender: Any) {
|
||||
invokeButton.isEnabled = false
|
||||
updateResultsText("Switched to the \(currentModel.description) model.")
|
||||
loadModel()
|
||||
}
|
||||
|
||||
@IBAction func invokeInterpreter(_ sender: Any) {
|
||||
switch currentModel {
|
||||
case .add:
|
||||
invokeAdd()
|
||||
case .addQuantized:
|
||||
invokeAddQuantized()
|
||||
case .multiAdd:
|
||||
invokeMultiAdd()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func loadModel() {
|
||||
let fileInfo = currentModel.fileInfo
|
||||
guard let modelPath = Bundle.main.path(forResource: fileInfo.name, ofType: fileInfo.extension)
|
||||
else {
|
||||
updateResultsText("Failed to load the \(currentModel.description) model.")
|
||||
return
|
||||
}
|
||||
setUpInterpreter(withModelPath: modelPath)
|
||||
}
|
||||
|
||||
private func setUpInterpreter(withModelPath modelPath: String) {
|
||||
interpreterQueue.async {
|
||||
do {
|
||||
var options = Interpreter.Options()
|
||||
options.threadCount = 2
|
||||
self.interpreter = try Interpreter(modelPath: modelPath, options: options)
|
||||
} catch let error {
|
||||
self.updateResultsText(
|
||||
"Failed to create the interpreter with error: \(error.localizedDescription)"
|
||||
)
|
||||
return
|
||||
}
|
||||
safeDispatchOnMain { self.invokeButton.isEnabled = true }
|
||||
}
|
||||
}
|
||||
|
||||
private func invokeAdd() {
|
||||
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: [Float32] = [1, 3]
|
||||
let resultsText = self.modelDescription + "\n\n" +
|
||||
"Performing 2 add operations on input \(input.description) equals: "
|
||||
self.updateResultsText(resultsText)
|
||||
let data = Data(copyingBufferOf: input)
|
||||
try interpreter.copy(data, toInputAt: 0)
|
||||
try interpreter.invoke()
|
||||
let outputTensor = try interpreter.output(at: 0)
|
||||
let results: () -> 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..<interpreter.inputTensorCount).forEach { index in
|
||||
try interpreter.resizeInput(at: index, to: shape)
|
||||
}
|
||||
try interpreter.allocateTensors()
|
||||
let inputs = try (0..<interpreter.inputTensorCount).map { index -> [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..<interpreter.outputTensorCount).map { index -> [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() }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user