提交 3d8aad9e 编写于 作者: L liuruilong

add metal loader and skeleton code

上级 e7bd3f7a
......@@ -69,3 +69,24 @@ build
# clion building directories
cmake-build-debug
cmake-build-release
# Pods
Podfile.lock
SwiftProtobuf.framework
metal/paddle-mobile/Pods/
example/paddle-mobile-demo/paddle-mobile-demo/yolo/
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
FC111A6620DD31C700F213F8 /* test.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC111A6520DD31C700F213F8 /* test.pb.swift */; };
FC111BE320DE079E00F213F8 /* params in Resources */ = {isa = PBXBuildFile; fileRef = FC111BE120DE079E00F213F8 /* params */; };
FC111BE420DE079E00F213F8 /* model in Resources */ = {isa = PBXBuildFile; fileRef = FC111BE220DE079E00F213F8 /* model */; };
FC9F52F120DA7F4D00C9F612 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC9F52F020DA7F4D00C9F612 /* AppDelegate.swift */; };
FC9F52F320DA7F4D00C9F612 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC9F52F220DA7F4D00C9F612 /* ViewController.swift */; };
FC9F52F620DA7F4D00C9F612 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC9F52F420DA7F4D00C9F612 /* Main.storyboard */; };
FC9F52F820DA7F4F00C9F612 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FC9F52F720DA7F4F00C9F612 /* Assets.xcassets */; };
FC9F52FB20DA7F4F00C9F612 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC9F52F920DA7F4F00C9F612 /* LaunchScreen.storyboard */; };
FCBF210620DC007900B5FDF0 /* paddle_mobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCBF210520DC007900B5FDF0 /* paddle_mobile.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
FCBF210720DC007900B5FDF0 /* paddle_mobile.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FCBF210520DC007900B5FDF0 /* paddle_mobile.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
FCBF210820DC00A100B5FDF0 /* SwiftProtobuf.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCBF20FC20DBFF4D00B5FDF0 /* SwiftProtobuf.framework */; };
FCBF210920DC00A100B5FDF0 /* SwiftProtobuf.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FCBF20FC20DBFF4D00B5FDF0 /* SwiftProtobuf.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
FCBF210420DC005100B5FDF0 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
FCBF210720DC007900B5FDF0 /* paddle_mobile.framework in Embed Frameworks */,
FCBF210920DC00A100B5FDF0 /* SwiftProtobuf.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
FC111A6520DD31C700F213F8 /* test.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = test.pb.swift; sourceTree = "<group>"; };
FC111BE120DE079E00F213F8 /* params */ = {isa = PBXFileReference; lastKnownFileType = file; path = params; sourceTree = "<group>"; };
FC111BE220DE079E00F213F8 /* model */ = {isa = PBXFileReference; lastKnownFileType = file; path = model; sourceTree = "<group>"; };
FC9F52ED20DA7F4D00C9F612 /* paddle-mobile-demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "paddle-mobile-demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
FC9F52F020DA7F4D00C9F612 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
FC9F52F220DA7F4D00C9F612 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
FC9F52F520DA7F4D00C9F612 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
FC9F52F720DA7F4F00C9F612 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
FC9F52FA20DA7F4F00C9F612 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
FC9F52FC20DA7F4F00C9F612 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
FCBF20FC20DBFF4D00B5FDF0 /* SwiftProtobuf.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SwiftProtobuf.framework; sourceTree = "<group>"; };
FCBF210520DC007900B5FDF0 /* paddle_mobile.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = paddle_mobile.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
FC9F52EA20DA7F4D00C9F612 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FCBF210620DC007900B5FDF0 /* paddle_mobile.framework in Frameworks */,
FCBF210820DC00A100B5FDF0 /* SwiftProtobuf.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
FC111BE020DE079E00F213F8 /* yolo */ = {
isa = PBXGroup;
children = (
FC111BE120DE079E00F213F8 /* params */,
FC111BE220DE079E00F213F8 /* model */,
);
path = yolo;
sourceTree = "<group>";
};
FC9F52E420DA7F4D00C9F612 = {
isa = PBXGroup;
children = (
FCBF210520DC007900B5FDF0 /* paddle_mobile.framework */,
FCBF20FC20DBFF4D00B5FDF0 /* SwiftProtobuf.framework */,
FC9F52EF20DA7F4D00C9F612 /* paddle-mobile-demo */,
FC9F52EE20DA7F4D00C9F612 /* Products */,
FCBF20F520DBFE7300B5FDF0 /* Frameworks */,
);
sourceTree = "<group>";
};
FC9F52EE20DA7F4D00C9F612 /* Products */ = {
isa = PBXGroup;
children = (
FC9F52ED20DA7F4D00C9F612 /* paddle-mobile-demo.app */,
);
name = Products;
sourceTree = "<group>";
};
FC9F52EF20DA7F4D00C9F612 /* paddle-mobile-demo */ = {
isa = PBXGroup;
children = (
FC111BE020DE079E00F213F8 /* yolo */,
FC111A6520DD31C700F213F8 /* test.pb.swift */,
FC9F52F020DA7F4D00C9F612 /* AppDelegate.swift */,
FC9F52F220DA7F4D00C9F612 /* ViewController.swift */,
FC9F52F420DA7F4D00C9F612 /* Main.storyboard */,
FC9F52F720DA7F4F00C9F612 /* Assets.xcassets */,
FC9F52F920DA7F4F00C9F612 /* LaunchScreen.storyboard */,
FC9F52FC20DA7F4F00C9F612 /* Info.plist */,
);
path = "paddle-mobile-demo";
sourceTree = "<group>";
};
FCBF20F520DBFE7300B5FDF0 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
FC9F52EC20DA7F4D00C9F612 /* paddle-mobile-demo */ = {
isa = PBXNativeTarget;
buildConfigurationList = FC9F52FF20DA7F4F00C9F612 /* Build configuration list for PBXNativeTarget "paddle-mobile-demo" */;
buildPhases = (
FC9F52E920DA7F4D00C9F612 /* Sources */,
FC9F52EA20DA7F4D00C9F612 /* Frameworks */,
FC9F52EB20DA7F4D00C9F612 /* Resources */,
FCBF210420DC005100B5FDF0 /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = "paddle-mobile-demo";
productName = "paddle-mobile-demo";
productReference = FC9F52ED20DA7F4D00C9F612 /* paddle-mobile-demo.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
FC9F52E520DA7F4D00C9F612 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0930;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = orange;
TargetAttributes = {
FC9F52EC20DA7F4D00C9F612 = {
CreatedOnToolsVersion = 9.3.1;
};
};
};
buildConfigurationList = FC9F52E820DA7F4D00C9F612 /* Build configuration list for PBXProject "paddle-mobile-demo" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = FC9F52E420DA7F4D00C9F612;
productRefGroup = FC9F52EE20DA7F4D00C9F612 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
FC9F52EC20DA7F4D00C9F612 /* paddle-mobile-demo */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
FC9F52EB20DA7F4D00C9F612 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FC9F52FB20DA7F4F00C9F612 /* LaunchScreen.storyboard in Resources */,
FC111BE420DE079E00F213F8 /* model in Resources */,
FC9F52F820DA7F4F00C9F612 /* Assets.xcassets in Resources */,
FC111BE320DE079E00F213F8 /* params in Resources */,
FC9F52F620DA7F4D00C9F612 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
FC9F52E920DA7F4D00C9F612 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FC9F52F320DA7F4D00C9F612 /* ViewController.swift in Sources */,
FC111A6620DD31C700F213F8 /* test.pb.swift in Sources */,
FC9F52F120DA7F4D00C9F612 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
FC9F52F420DA7F4D00C9F612 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
FC9F52F520DA7F4D00C9F612 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
FC9F52F920DA7F4F00C9F612 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
FC9F52FA20DA7F4F00C9F612 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
FC9F52FD20DA7F4F00C9F612 /* 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.3;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
FC9F52FE20DA7F4F00C9F612 /* 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.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
FC9F530020DA7F4F00C9F612 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Z5M2UUN5YV;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = "paddle-mobile-demo/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "orange.paddle-mobile-demo";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
FC9F530120DA7F4F00C9F612 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Z5M2UUN5YV;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = "paddle-mobile-demo/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "orange.paddle-mobile-demo";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
FC9F52E820DA7F4D00C9F612 /* Build configuration list for PBXProject "paddle-mobile-demo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FC9F52FD20DA7F4F00C9F612 /* Debug */,
FC9F52FE20DA7F4F00C9F612 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FC9F52FF20DA7F4F00C9F612 /* Build configuration list for PBXNativeTarget "paddle-mobile-demo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FC9F530020DA7F4F00C9F612 /* Debug */,
FC9F530120DA7F4F00C9F612 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = FC9F52E520DA7F4D00C9F612 /* Project object */;
}
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:paddle-mobile-demo.xcodeproj">
</FileRef>
</Workspace>
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?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>SchemeUserState</key>
<dict>
<key>paddle-mobile-demo.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
</dict>
</dict>
</plist>
//
// AppDelegate.swift
// paddle-mobile-demo
//
// Created by liuRuiLong on 2018/6/20.
// Copyright © 2018年 orange. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
{
"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
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<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">
<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"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<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"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
<?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>$(DEVELOPMENT_LANGUAGE)</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>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<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>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
//
// ViewController.swift
// paddle-mobile-demo
//
// Created by liuRuiLong on 2018/6/20.
// Copyright © 2018年 orange. All rights reserved.
//
import UIKit
import paddle_mobile
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
var date = Date.init()
if let modelPath = Bundle.main.path(forResource: "model", ofType: nil), let paraPath = Bundle.main.path(forResource: "params", ofType: nil) {
print(" bundlepath: " + modelPath)
let loader = Loader<Float32>.init()
try! loader.load(modelPath: modelPath, paraPath: paraPath)
}
let els = Date.init().timeIntervalSince(date)
print(els)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
// DO NOT EDIT.
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: test.proto
//
// For information on using the generated types, please see the documenation:
// https://github.com/apple/swift-protobuf/
import Foundation
import SwiftProtobuf
// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that your are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
typealias Version = _2
}
struct BookInfo {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var id: Int64 = 0
var title: String = String()
var author: String = String()
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
}
// MARK: - Code below here is support for the SwiftProtobuf runtime.
extension BookInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = "BookInfo"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "id"),
2: .same(proto: "title"),
3: .same(proto: "author"),
]
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularInt64Field(value: &self.id)
case 2: try decoder.decodeSingularStringField(value: &self.title)
case 3: try decoder.decodeSingularStringField(value: &self.author)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if self.id != 0 {
try visitor.visitSingularInt64Field(value: self.id, fieldNumber: 1)
}
if !self.title.isEmpty {
try visitor.visitSingularStringField(value: self.title, fieldNumber: 2)
}
if !self.author.isEmpty {
try visitor.visitSingularStringField(value: self.author, fieldNumber: 3)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: BookInfo) -> Bool {
if self.id != other.id {return false}
if self.title != other.title {return false}
if self.author != other.author {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
platform :ios, 9.0
use_frameworks!
target 'paddle-mobile-demo' do
pod 'SwiftProtobuf', '~> 1.0'
end
target 'paddle-mobile' do
pod 'SwiftProtobuf', '~> 1.0'
end
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
12F10C488EAE0B360E3ED522 /* Pods_paddle_mobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7379EE496BCB959550E49F06 /* Pods_paddle_mobile.framework */; };
FC111A6A20DD4DE200F213F8 /* BlockDesc.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC111A6920DD4DE200F213F8 /* BlockDesc.swift */; };
FC111A6C20DD4DEC00F213F8 /* VarDesc.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC111A6B20DD4DEC00F213F8 /* VarDesc.swift */; };
FC111A6E20DD4DF500F213F8 /* TensorDesc.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC111A6D20DD4DF500F213F8 /* TensorDesc.swift */; };
FC111A7020DD50AB00F213F8 /* OpDesc.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC111A6F20DD50AB00F213F8 /* OpDesc.swift */; };
FC111A7220DDED3D00F213F8 /* Attribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC111A7120DDED3D00F213F8 /* Attribute.swift */; };
FC111BE620DE088600F213F8 /* Program.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC111BE520DE088600F213F8 /* Program.swift */; };
FC2712A720DE11FE007BC206 /* Tensor.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2712A620DE11FE007BC206 /* Tensor.swift */; };
FC2712A920DE1206007BC206 /* Dim.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2712A820DE1206007BC206 /* Dim.swift */; };
FC2712AB20DE2340007BC206 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2712AA20DE2340007BC206 /* Types.swift */; };
FC2712AD20DE5060007BC206 /* Scope.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2712AC20DE5060007BC206 /* Scope.swift */; };
FC2712AF20DEA008007BC206 /* Operator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2712AE20DEA008007BC206 /* Operator.swift */; };
FC2712B220DEA108007BC206 /* ConvOp.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2712B120DEA108007BC206 /* ConvOp.swift */; };
FC88679D20E0F47900A29C00 /* Executor.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC88679C20E0F47900A29C00 /* Executor.swift */; };
FC9F530720DA7FB700C9F612 /* ProgramDesc.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC9F530620DA7FB700C9F612 /* ProgramDesc.swift */; };
FC9F530A20DA835D00C9F612 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC9F530920DA835D00C9F612 /* Extensions.swift */; };
FC9F530C20DA83A700C9F612 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC9F530B20DA83A700C9F612 /* Errors.swift */; };
FC9F530E20DA861D00C9F612 /* framework.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC9F530D20DA861D00C9F612 /* framework.pb.swift */; };
FCB7C3FA20DF885900156259 /* ReluOp.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCB7C3F920DF885900156259 /* ReluOp.swift */; };
FCB7C3FC20DF8EEE00156259 /* BatchNormOp.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCB7C3FB20DF8EEE00156259 /* BatchNormOp.swift */; };
FCB7C3FE20DFE49B00156259 /* ElementwiseAddOp.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCB7C3FD20DFE49B00156259 /* ElementwiseAddOp.swift */; };
FCBA505920DA7A1100044AA3 /* paddle_mobile.h in Headers */ = {isa = PBXBuildFile; fileRef = FCBA505720DA7A1100044AA3 /* paddle_mobile.h */; settings = {ATTRIBUTES = (Public, ); }; };
FCBA506020DA7CEF00044AA3 /* Loader.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCBA505F20DA7CEF00044AA3 /* Loader.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
1BA510B509FF05304A0AA5CF /* Pods-paddle-mobile.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paddle-mobile.release.xcconfig"; path = "Pods/Target Support Files/Pods-paddle-mobile/Pods-paddle-mobile.release.xcconfig"; sourceTree = "<group>"; };
637CE9BBF82421D0FAECA982 /* Pods-paddle-mobile.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paddle-mobile.debug.xcconfig"; path = "Pods/Target Support Files/Pods-paddle-mobile/Pods-paddle-mobile.debug.xcconfig"; sourceTree = "<group>"; };
7379EE496BCB959550E49F06 /* Pods_paddle_mobile.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_paddle_mobile.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FC111A6920DD4DE200F213F8 /* BlockDesc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockDesc.swift; sourceTree = "<group>"; };
FC111A6B20DD4DEC00F213F8 /* VarDesc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VarDesc.swift; sourceTree = "<group>"; };
FC111A6D20DD4DF500F213F8 /* TensorDesc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TensorDesc.swift; sourceTree = "<group>"; };
FC111A6F20DD50AB00F213F8 /* OpDesc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpDesc.swift; sourceTree = "<group>"; };
FC111A7120DDED3D00F213F8 /* Attribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Attribute.swift; sourceTree = "<group>"; };
FC111BE520DE088600F213F8 /* Program.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Program.swift; sourceTree = "<group>"; };
FC2712A620DE11FE007BC206 /* Tensor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tensor.swift; sourceTree = "<group>"; };
FC2712A820DE1206007BC206 /* Dim.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dim.swift; sourceTree = "<group>"; };
FC2712AA20DE2340007BC206 /* Types.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Types.swift; sourceTree = "<group>"; };
FC2712AC20DE5060007BC206 /* Scope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Scope.swift; sourceTree = "<group>"; };
FC2712AE20DEA008007BC206 /* Operator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Operator.swift; sourceTree = "<group>"; };
FC2712B120DEA108007BC206 /* ConvOp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConvOp.swift; sourceTree = "<group>"; };
FC88679C20E0F47900A29C00 /* Executor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Executor.swift; sourceTree = "<group>"; };
FC9F530620DA7FB700C9F612 /* ProgramDesc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgramDesc.swift; sourceTree = "<group>"; };
FC9F530920DA835D00C9F612 /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
FC9F530B20DA83A700C9F612 /* Errors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
FC9F530D20DA861D00C9F612 /* framework.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = framework.pb.swift; sourceTree = "<group>"; };
FCB7C3F920DF885900156259 /* ReluOp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReluOp.swift; sourceTree = "<group>"; };
FCB7C3FB20DF8EEE00156259 /* BatchNormOp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatchNormOp.swift; sourceTree = "<group>"; };
FCB7C3FD20DFE49B00156259 /* ElementwiseAddOp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementwiseAddOp.swift; sourceTree = "<group>"; };
FCBA505420DA7A1100044AA3 /* paddle_mobile.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = paddle_mobile.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FCBA505720DA7A1100044AA3 /* paddle_mobile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = paddle_mobile.h; sourceTree = "<group>"; };
FCBA505820DA7A1100044AA3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
FCBA505F20DA7CEF00044AA3 /* Loader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Loader.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
FCBA505020DA7A1100044AA3 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
12F10C488EAE0B360E3ED522 /* Pods_paddle_mobile.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
C496DE8B9216803C3A836198 /* Pods */ = {
isa = PBXGroup;
children = (
637CE9BBF82421D0FAECA982 /* Pods-paddle-mobile.debug.xcconfig */,
1BA510B509FF05304A0AA5CF /* Pods-paddle-mobile.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
E707ADA0AE1047E37B361DCE /* Frameworks */ = {
isa = PBXGroup;
children = (
7379EE496BCB959550E49F06 /* Pods_paddle_mobile.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
FC2712A520DE11F1007BC206 /* framework */ = {
isa = PBXGroup;
children = (
FC2712A620DE11FE007BC206 /* Tensor.swift */,
FC2712A820DE1206007BC206 /* Dim.swift */,
);
path = framework;
sourceTree = "<group>";
};
FC2712B020DEA0FE007BC206 /* Operators */ = {
isa = PBXGroup;
children = (
FC2712AE20DEA008007BC206 /* Operator.swift */,
FC2712B120DEA108007BC206 /* ConvOp.swift */,
FCB7C3F920DF885900156259 /* ReluOp.swift */,
FCB7C3FB20DF8EEE00156259 /* BatchNormOp.swift */,
FCB7C3FD20DFE49B00156259 /* ElementwiseAddOp.swift */,
);
path = Operators;
sourceTree = "<group>";
};
FC9F52E320DA7E7E00C9F612 /* Program */ = {
isa = PBXGroup;
children = (
FC9F530D20DA861D00C9F612 /* framework.pb.swift */,
FC9F530620DA7FB700C9F612 /* ProgramDesc.swift */,
FC111A6920DD4DE200F213F8 /* BlockDesc.swift */,
FC111A6B20DD4DEC00F213F8 /* VarDesc.swift */,
FC111A6D20DD4DF500F213F8 /* TensorDesc.swift */,
FC111A6F20DD50AB00F213F8 /* OpDesc.swift */,
FC111A7120DDED3D00F213F8 /* Attribute.swift */,
FC111BE520DE088600F213F8 /* Program.swift */,
FC2712AC20DE5060007BC206 /* Scope.swift */,
);
path = Program;
sourceTree = "<group>";
};
FC9F530820DA835700C9F612 /* Common */ = {
isa = PBXGroup;
children = (
FC9F530920DA835D00C9F612 /* Extensions.swift */,
FC9F530B20DA83A700C9F612 /* Errors.swift */,
FC2712AA20DE2340007BC206 /* Types.swift */,
);
path = Common;
sourceTree = "<group>";
};
FCBA504A20DA7A1100044AA3 = {
isa = PBXGroup;
children = (
FCBA505620DA7A1100044AA3 /* paddle-mobile */,
FCBA505520DA7A1100044AA3 /* Products */,
C496DE8B9216803C3A836198 /* Pods */,
E707ADA0AE1047E37B361DCE /* Frameworks */,
);
sourceTree = "<group>";
};
FCBA505520DA7A1100044AA3 /* Products */ = {
isa = PBXGroup;
children = (
FCBA505420DA7A1100044AA3 /* paddle_mobile.framework */,
);
name = Products;
sourceTree = "<group>";
};
FCBA505620DA7A1100044AA3 /* paddle-mobile */ = {
isa = PBXGroup;
children = (
FC2712B020DEA0FE007BC206 /* Operators */,
FC2712A520DE11F1007BC206 /* framework */,
FC9F530820DA835700C9F612 /* Common */,
FC9F52E320DA7E7E00C9F612 /* Program */,
FCBA505720DA7A1100044AA3 /* paddle_mobile.h */,
FCBA505820DA7A1100044AA3 /* Info.plist */,
FCBA505F20DA7CEF00044AA3 /* Loader.swift */,
FC88679C20E0F47900A29C00 /* Executor.swift */,
);
path = "paddle-mobile";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
FCBA505120DA7A1100044AA3 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
FCBA505920DA7A1100044AA3 /* paddle_mobile.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
FCBA505320DA7A1100044AA3 /* paddle-mobile */ = {
isa = PBXNativeTarget;
buildConfigurationList = FCBA505C20DA7A1100044AA3 /* Build configuration list for PBXNativeTarget "paddle-mobile" */;
buildPhases = (
522C71CE8D72187FBDA21FBA /* [CP] Check Pods Manifest.lock */,
FCBA504F20DA7A1100044AA3 /* Sources */,
FCBA505020DA7A1100044AA3 /* Frameworks */,
FCBA505120DA7A1100044AA3 /* Headers */,
FCBA505220DA7A1100044AA3 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "paddle-mobile";
productName = "paddle-mobile";
productReference = FCBA505420DA7A1100044AA3 /* paddle_mobile.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
FCBA504B20DA7A1100044AA3 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = orange;
TargetAttributes = {
FCBA505320DA7A1100044AA3 = {
CreatedOnToolsVersion = 9.3.1;
LastSwiftMigration = 0930;
};
};
};
buildConfigurationList = FCBA504E20DA7A1100044AA3 /* Build configuration list for PBXProject "paddle-mobile" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = FCBA504A20DA7A1100044AA3;
productRefGroup = FCBA505520DA7A1100044AA3 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
FCBA505320DA7A1100044AA3 /* paddle-mobile */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
FCBA505220DA7A1100044AA3 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
522C71CE8D72187FBDA21FBA /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-paddle-mobile-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
FCBA504F20DA7A1100044AA3 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FC111A7220DDED3D00F213F8 /* Attribute.swift in Sources */,
FC9F530C20DA83A700C9F612 /* Errors.swift in Sources */,
FC111A7020DD50AB00F213F8 /* OpDesc.swift in Sources */,
FC2712AB20DE2340007BC206 /* Types.swift in Sources */,
FC2712AD20DE5060007BC206 /* Scope.swift in Sources */,
FC2712AF20DEA008007BC206 /* Operator.swift in Sources */,
FCBA506020DA7CEF00044AA3 /* Loader.swift in Sources */,
FCB7C3FC20DF8EEE00156259 /* BatchNormOp.swift in Sources */,
FC111A6C20DD4DEC00F213F8 /* VarDesc.swift in Sources */,
FC111A6A20DD4DE200F213F8 /* BlockDesc.swift in Sources */,
FC2712A720DE11FE007BC206 /* Tensor.swift in Sources */,
FC111BE620DE088600F213F8 /* Program.swift in Sources */,
FC2712B220DEA108007BC206 /* ConvOp.swift in Sources */,
FC88679D20E0F47900A29C00 /* Executor.swift in Sources */,
FC9F530E20DA861D00C9F612 /* framework.pb.swift in Sources */,
FC2712A920DE1206007BC206 /* Dim.swift in Sources */,
FCB7C3FE20DFE49B00156259 /* ElementwiseAddOp.swift in Sources */,
FC111A6E20DD4DF500F213F8 /* TensorDesc.swift in Sources */,
FC9F530A20DA835D00C9F612 /* Extensions.swift in Sources */,
FCB7C3FA20DF885900156259 /* ReluOp.swift in Sources */,
FC9F530720DA7FB700C9F612 /* ProgramDesc.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
FCBA505A20DA7A1100044AA3 /* 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;
CURRENT_PROJECT_VERSION = 1;
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.3;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
FCBA505B20DA7A1100044AA3 /* 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;
CURRENT_PROJECT_VERSION = 1;
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.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
FCBA505D20DA7A1100044AA3 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 637CE9BBF82421D0FAECA982 /* Pods-paddle-mobile.debug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = Z5M2UUN5YV;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "paddle-mobile/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MACH_O_TYPE = staticlib;
PRODUCT_BUNDLE_IDENTIFIER = "orange.paddle-mobile";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
FCBA505E20DA7A1100044AA3 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 1BA510B509FF05304A0AA5CF /* Pods-paddle-mobile.release.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = Z5M2UUN5YV;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "paddle-mobile/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MACH_O_TYPE = staticlib;
PRODUCT_BUNDLE_IDENTIFIER = "orange.paddle-mobile";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
FCBA504E20DA7A1100044AA3 /* Build configuration list for PBXProject "paddle-mobile" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FCBA505A20DA7A1100044AA3 /* Debug */,
FCBA505B20DA7A1100044AA3 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FCBA505C20DA7A1100044AA3 /* Build configuration list for PBXNativeTarget "paddle-mobile" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FCBA505D20DA7A1100044AA3 /* Debug */,
FCBA505E20DA7A1100044AA3 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = FCBA504B20DA7A1100044AA3 /* Project object */;
}
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:paddle-mobile.xcodeproj">
</FileRef>
</Workspace>
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?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>SchemeUserState</key>
<dict>
<key>paddle-mobile.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
</dict>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:../../example/paddle-mobile-demo/paddle-mobile-demo.xcodeproj">
</FileRef>
<FileRef
location = "group:paddle-mobile.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "0"
version = "2.0">
</Bucket>
/* Copyright (c) 2018 PaddlePaddle Authors. 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
public enum PaddleMobileError: Error{
case loaderError(message: String)
case netError(message: String)
case memoryError(message: String)
case paramError(message: String)
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
// 自定义 ?! 如果 ?! 前的返回值为一个可选值, 则进行隐式解包, 如果有值则返回这个值, 如果为nil 则fatalError 传入的信息
precedencegroup ExecutedOrFatalError{
associativity: left
higherThan: AssignmentPrecedence
}
infix operator ?!: ExecutedOrFatalError
func ?!<T>(option: T?, excuteOrError: @autoclosure () -> String) -> T{
if let inOpt = option {
return inOpt
}else{
fatalError(excuteOrError())
}
}
//Lense
struct Lense<A, B> {
let from: (A) -> B
let to: (B, A) -> A
}
precedencegroup CombineLense{
associativity: left
higherThan: AssignmentPrecedence
}
infix operator >>>: CombineLense
func >>><A, B, C>(left: Lense<B, C>, right: Lense<A, B>) -> Lense<A, C> {
return Lense<A, C>.init(from: { (a) -> C in
left.from(right.from(a))
}, to: { (c, a) -> A in
right.to( left.to(c, right.from(a)),a)
})
}
protocol CIntIndex {
associatedtype T;
subscript(index: CInt) -> T { get set};
}
extension Array: CIntIndex{
typealias T = Element
subscript(index: CInt) -> T {
get{
guard Int64(Int.max) >= Int64(index) else{
fatalError("cint index out of Int range")
}
return self[Int(index)]
}
set{
guard Int64(Int.max) >= Int64(index) else{
fatalError("cint index out of Int range")
}
self[Int(index)] = newValue
}
}
}
//MARK: Array extension
extension Array where Element: Comparable{
/// 返回数组前 r 个元素, 并将元素处于原数组的位置作为元组的第一个元素返回
///
/// - Parameter r: 前 r 个元素
/// - Returns: [(原有位置, 排好位置的元素)]
func top(r: Int) -> [(Int, Element)] {
precondition(r <= self.count)
return Array<(Int, Element)>(zip(0..<self.count, self).sorted{ $0.1 > $1.1 }.prefix(through: r - 1))
}
}
extension String{
func cStr() -> UnsafePointer<Int8>? {
return (self as NSString).utf8String
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
//typealias Float16 = Int16
//extension Float16: PrecisionType {
//}
public protocol PrecisionType {
}
extension Float32: PrecisionType {
}
enum DataLayout {
case NCHW
case NHWC
}
protocol Variant {
}
extension Tensor: Variant {
}
let gConvType = "conv2d"
let gBatchNormType = "batch_norm"
let gReluType = "relu"
let gElementwiseAdd = "elementwise_add"
let opInputsOutputsKey = [gConvType : (inputs: ["Input"], outputs: ["Output"]),
gBatchNormType : (inputs: ["X"], outputs: ["Y"]),
gReluType : (inputs: ["X"], outputs: ["Out"]),
gElementwiseAdd : (inputs: ["X", "Y"], outputs: ["Out"])]
/* Copyright (c) 2018 PaddlePaddle Authors. 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
class Executor {
}
<?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>$(DEVELOPMENT_LANGUAGE)</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>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
/* Copyright (c) 2018 PaddlePaddle Authors. 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
import SwiftProtobuf
class ParamData<P: PrecisionType> {
let size: Int
var dim: Dim
private(set) var layout: DataLayout
var pointer: UnsafeMutablePointer<P>
init(inDim: Dim, inLayout: DataLayout = .NCHW) {
dim = inDim
size = inDim.numel() * MemoryLayout<P>.size
pointer = UnsafeMutablePointer<P>.allocate(capacity: size)
layout = inLayout
}
func convert(to: DataLayout) {
guard to != layout else {
return
}
guard dim.cout() == 4 else {
return
}
guard layout == .NCHW && to == .NHWC else {
// other not support
return
}
let newPointer = UnsafeMutablePointer<P>.allocate(capacity: size)
if layout == .NCHW {
NCHW2NHWC(newPtr: newPointer)
}
pointer.deinitialize(count: size)
pointer.deallocate()
pointer = newPointer
layout = to
}
func NCHW2NHWC(newPtr: UnsafeMutablePointer<P>) {
let N = dim[0]
let C = dim[1]
let H = dim[2]
let W = dim[3]
let HXW = H * W
let CXHXW = C * H * W
var index: Int = 0
for n in 0..<N {
for h in 0..<H{
for w in 0..<W{
for c in 0..<C{
newPtr[index] = pointer[n * CXHXW + c * HXW + h * w + w]
index += 1
}
}
}
}
dim.swapeDimAt(index1: 1, index2: 3)
}
deinit {
pointer.deinitialize(count: size)
pointer.deallocate()
}
}
public class Loader<P: PrecisionType> {
class ParaLoader {
let file: UnsafeMutablePointer<FILE>
let fileSize: Int
var nowIndex: Int
init(paramPath: String) throws {
guard let tmpFile = fopen(paramPath, "rb") else {
throw PaddleMobileError.loaderError(message: "open param file error" + paramPath)
}
file = tmpFile
fseek(file, 0, SEEK_END)
fileSize = ftell(file)
guard fileSize > 0 else {
throw PaddleMobileError.loaderError(message: "param file size is too small")
}
rewind(file)
nowIndex = 0
}
func read(data: ParamData<P>) throws {
guard nowIndex <= fileSize else {
throw PaddleMobileError.loaderError(message: "out of the file range")
}
func pointerReader<T>(type: T.Type) -> T {
let ptr = UnsafeMutablePointer<T>.allocate(capacity: MemoryLayout<T>.size)
fread(ptr, 1, MemoryLayout<T>.size, file)
nowIndex += MemoryLayout<T>.size
let pointee = ptr.pointee
ptr.deinitialize(count: MemoryLayout<UInt32>.size)
ptr.deallocate()
return pointee
}
_ = pointerReader(type: UInt32.self)
let lodLevel = pointerReader(type: UInt64.self)
for _ in 0..<lodLevel {
let size = pointerReader(type: UInt64.self)
for _ in 0..<Int(size/UInt64(MemoryLayout<size_t>.size)){
_ = pointerReader(type: size_t.self)
}
}
let _ = pointerReader(type: UInt32.self)
let tensorDescSize = pointerReader(type: Int32.self)
fseek(file, Int(tensorDescSize), SEEK_CUR)
nowIndex += Int(tensorDescSize)
/*
这里没有根据 Data Type 去判断, 而是从外部泛型直接指定了精度
*/
let bytesRead = fread(data.pointer, 1, data.size, file)
guard bytesRead == data.size else {
throw PaddleMobileError.loaderError(message: "param read size error")
}
nowIndex += bytesRead
}
deinit {
fclose(file)
}
}
public init(){}
public func load(modelPath: String, paraPath: String) throws -> Program{
guard let modelData = try? Data.init(contentsOf: URL.init(fileURLWithPath: modelPath)) else {
throw PaddleMobileError.loaderError(message: "load " + modelPath + " failed !")
}
do {
let protoProgram = try PaddleMobile_Framework_Proto_ProgramDesc.init(
serializedData: modelData)
let scope = Scope.init()
let program = Program.init(protoProgramDesc: protoProgram, inParamPath: paraPath, inScope: scope)
guard let paraLoader = try? ParaLoader.init(paramPath: paraPath) else {
throw PaddleMobileError.loaderError(message: "load para error")
}
for block in program.programDesc.blocks {
for varDesc in block.vars {
if (varDesc.type == .LodTensor) {
if (varDesc.persistable
&& varDesc.type != .FeedMiniBatch
&& varDesc.type != .FetchList) {
guard let tensorDesc = varDesc.tensorDesc else {
throw PaddleMobileError.loaderError(message: "get tensor desc failed")
}
guard (try? tensorDesc.dataType.dataTypeSize()) == MemoryLayout<P>.size else {
throw PaddleMobileError.memoryError(message: "PrecisionType not support")
}
let dimArr = tensorDesc.dims
guard dimArr.count > 0 else {
throw PaddleMobileError.loaderError(message: "tensor desc dim size error")
}
let dim = Dim.init(inDim: dimArr)
let paraData = ParamData<P>.init(inDim: dim)
do {
try paraLoader.read(data: paraData)
} catch let error {
throw error
}
paraData.convert(to: .NHWC)
let tensor = Tensor<P>.init(inData: paraData)
scope.vars[varDesc.name] = tensor
}
}
}
}
return program
} catch _ {
throw PaddleMobileError.loaderError(message: "protobuf decoder error")
}
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
struct BatchNormParam<P: PrecisionType>: Param {
typealias ParamP = P
init(opDesc: OpDesc, scope: Scope) throws {
do {
inputX = try BatchNormParam.inputX(inputs: opDesc.inputs, from: scope)
outputY = try BatchNormParam.outputY(outputs: opDesc.outputs, from: scope)
inputBias = try BatchNormParam.inputBiase(inputs: opDesc.paraInputs, from: scope)
inputMean = try BatchNormParam.inputMean(inputs: opDesc.paraInputs, from: scope)
inputScale = try BatchNormParam.inputScale(inputs: opDesc.paraInputs, from: scope)
inputVariance = try BatchNormParam.inputVariance(inputs: opDesc.paraInputs, from: scope)
epsilon = try BatchNormParam.getAttr(key: "epsilon", attrs: opDesc.attrs)
momentum = try BatchNormParam.getAttr(key: "momentum", attrs: opDesc.attrs)
is_test = try BatchNormParam.getAttr(key: "is_test", attrs: opDesc.attrs)
} catch let error {
throw error
}
}
let inputX: Tensor<ParamP>
let outputY: Tensor<ParamP>
let inputBias: Tensor<ParamP>
let inputMean: Tensor<ParamP>
let inputScale: Tensor<ParamP>
let inputVariance: Tensor<ParamP>
let epsilon: Float
let momentum: Float
let is_test: Bool
}
class BatchNormOp<P: PrecisionType>: Operator<BatchNormParam<P>> {
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
struct ConvParam<P: PrecisionType>: Param {
typealias ParamP = P
init(opDesc: OpDesc, scope: Scope) throws {
do {
filter = try ConvParam.inputFilter(paraInputs: opDesc.paraInputs, from: scope)
input = try ConvParam.input(inputs: opDesc.inputs, from: scope)
output = try ConvParam.output(outputs: opDesc.outputs, from: scope)
stride = try ConvParam.getAttr(key: "stride", attrs: opDesc.attrs)
paddings = try ConvParam.getAttr(key: "paddings", attrs: opDesc.attrs)
dilations = try ConvParam.getAttr(key: "dilations", attrs: opDesc.attrs)
groups = try ConvParam.getAttr(key: "groups", attrs: opDesc.attrs)
} catch let error {
throw error
}
}
let input: Tensor<ParamP>
let output: Tensor<ParamP>
let filter: Tensor<ParamP>
let stride: [Int]
let paddings: [Int]
let dilations: [Int]
let groups: Int
}
class ConvOp<P: PrecisionType>: Operator<ConvParam<P>> {
override func runImpl() {
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
struct ElementwiseAddParam<P: PrecisionType>: Param {
typealias ParamP = P
init(opDesc: OpDesc, scope: Scope) throws {
do {
inputX = try ElementwiseAddParam.inputX(inputs: opDesc.inputs, from: scope)
inputY = try ElementwiseAddParam.inputY(inputs: opDesc.inputs, from: scope)
out = try ElementwiseAddParam.outputOut(outputs: opDesc.outputs, from: scope)
axis = try ElementwiseAddParam.getAttr(key: "axis", attrs: opDesc.attrs)
} catch let error {
throw error
}
}
let inputX: Tensor<P>
let inputY: Tensor<P>
let out: Tensor<P>
let axis: Int
}
class ElementwiseAddOp<P: PrecisionType>: Operator<ElementwiseAddParam<P>>{
override func runImpl() {
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
/*
let opInputsOutputsKey = [gConvType : (inputs: ["Input"], outputs: ["Output"]),
gBatchNormType : (inputs: ["X"], outputs: ["Y"]),
gReluType : (inputs: ["X"], outputs: ["Out"]),
gElementwiseAdd : (inputs: ["X", "Y"], outputs: ["Out"])]
*/
protocol Param {
associatedtype ParamP: PrecisionType
init(opDesc: OpDesc, scope: Scope) throws
static func getFirstTensor(key: String, map: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func inputX(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func inputBiase(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func inputMean(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func inputScale(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func inputVariance(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func inputFilter(paraInputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func input(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func output(outputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func outputY(outputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func inputY(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func outputOut(outputs: [String : [String]], from: Scope) throws -> Tensor<ParamP>
static func getAttr<T>(key: String, attrs: [String : Attr]) throws -> T
}
extension Param {
static func getFirstTensor(key: String, map: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
guard let mapKeys = map["X"], mapKeys.count > 0, let inputX = from[mapKeys[0]], let tensorX = inputX as? Tensor<ParamP> else {
throw PaddleMobileError.paramError(message: "tensor " + key + "in \(map) not found")
}
return tensorX
}
static func inputX(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorX = try getFirstTensor(key: "X", map: inputs, from: from)
return tensorX
} catch let error {
throw error
}
}
static func input(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorInput = try getFirstTensor(key: "Input", map: inputs, from: from)
return tensorInput
} catch let error {
throw error
}
}
static func output(outputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorOutput = try getFirstTensor(key: "Output", map: outputs, from: from)
return tensorOutput
} catch let error {
throw error
}
}
static func outputY(outputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorOutputY = try getFirstTensor(key: "Y", map: outputs, from: from)
return tensorOutputY
} catch let error {
throw error
}
}
static func inputY(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorY = try getFirstTensor(key: "Y", map: inputs, from: from)
return tensorY
} catch let error {
throw error
}
}
static func outputOut(outputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let out = try getFirstTensor(key: "Out", map: outputs, from: from)
return out
} catch let error {
throw error
}
}
static func inputFilter(paraInputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorFilter = try getFirstTensor(key: "Filter", map: paraInputs, from: from)
return tensorFilter
} catch let error {
throw error
}
}
static func inputBiase(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorBias = try getFirstTensor(key: "Bias", map: inputs, from: from)
return tensorBias
} catch let error {
throw error
}
}
static func inputMean(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorMean = try getFirstTensor(key: "Mean", map: inputs, from: from)
return tensorMean
} catch let error {
throw error
}
}
static func inputScale(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorScale = try getFirstTensor(key: "Scale", map: inputs, from: from)
return tensorScale
} catch let error {
throw error
}
}
static func inputVariance(inputs: [String : [String]], from: Scope) throws -> Tensor<ParamP> {
do {
let tensorVariance = try getFirstTensor(key: "Variance", map: inputs, from: from)
return tensorVariance
} catch let error {
throw error
}
}
static func getAttr<T>(key: String, attrs: [String : Attr]) throws -> T{
guard let attr = attrs[key] as? T else {
throw PaddleMobileError.paramError(message: "attr type error")
}
return attr
}
}
class Operator<ParamType: Param> {
let type: String
let inputs: [String : [String]]
let paraInputs: [String : [String]]
let outpus: [String : [String]]
let attrs: [String : Attr]
let para: ParamType
init(opDesc: OpDesc, inScope: Scope) throws {
type = opDesc.type
inputs = opDesc.inputs
outpus = opDesc.outputs
attrs = opDesc.attrs
paraInputs = opDesc.paraInputs
do {
para = try ParamType.init(opDesc:opDesc, scope: inScope)
} catch let error {
throw error
}
}
func run() {
runImpl()
}
func runImpl() {
fatalError("runimpl of " + type + "op not implement")
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
struct ReluParam<P: PrecisionType>: Param {
typealias ParamP = P
init(opDesc: OpDesc, scope: Scope) throws {
do {
inputX = try ReluParam.inputX(inputs: opDesc.inputs, from: scope)
out = try ReluParam.outputOut(outputs: opDesc.outputs, from: scope)
} catch let error {
throw error
}
}
let inputX: Tensor<ParamP>
let out: Tensor<ParamP>
}
class ReluOp<P: PrecisionType>: Operator<ReluParam<P>> {
override func runImpl() {
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
protocol Attr {
}
extension Bool: Attr {
}
extension Int: Attr {
}
extension Float: Attr {
}
extension Int64: Attr {
}
extension Array: Attr {
}
func attrWithProtoDesc(attrDesc: PaddleMobile_Framework_Proto_OpDesc.Attr) -> Attr {
switch attrDesc.type {
case .boolean:
return attrDesc.b
case .int:
return Int(attrDesc.i)
case .string:
return attrDesc.strings
case .long:
return attrDesc.l
case .float:
return attrDesc.f
case .booleans:
return attrDesc.bools
case .floats:
return attrDesc.floats
case .ints:
return attrDesc.ints
case .strings:
return attrDesc.strings
default:
fatalError(" not support this attr type: \(attrDesc.type)")
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
struct BlockDesc {
let index: Int
let parentIndex: Int
let vars: [VarDesc]
let ops: [OpDesc]
init(block: PaddleMobile_Framework_Proto_BlockDesc) {
index = Int(block.idx)
parentIndex = Int(block.parentIdx)
var vars: [VarDesc] = []
for varOfBlock in block.vars {
vars.append(VarDesc.init(protoVarDesc: varOfBlock))
}
vars.sort { $0.name < $1.name }
self.vars = vars
var ops: [OpDesc] = []
for op in block.ops {
ops.append(OpDesc.init(protoOpDesc: op))
}
self.ops = ops
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
struct OpDesc {
let inputs: [String : [String]]
let paraInputs: [String : [String]]
let outputs: [String : [String]]
let unusedOutputs: [String : [String]]
var attrs: [String : Attr] = [:]
let type: String
init(protoOpDesc: PaddleMobile_Framework_Proto_OpDesc) {
type = protoOpDesc.type
let creator = { (vars: [PaddleMobile_Framework_Proto_OpDesc.Var], canAdd: (String) -> Bool) -> [String : [String]] in
var map: [String : [String]] = [:]
for opDescVar in vars {
if (canAdd(opDescVar.parameter)) {
map[opDescVar.parameter] = opDescVar.arguments
}
}
return map
}
inputs = creator(protoOpDesc.inputs) {
opInputsOutputsKey[protoOpDesc.type]?.inputs.contains($0) ?? false
}
paraInputs = creator(protoOpDesc.inputs) {
!(opInputsOutputsKey[protoOpDesc.type]?.inputs.contains($0) ?? false)
}
outputs = creator(protoOpDesc.outputs) {
opInputsOutputsKey[protoOpDesc.type]?.outputs.contains($0) ?? false
}
unusedOutputs = creator(protoOpDesc.outputs) {
!(opInputsOutputsKey[protoOpDesc.type]?.outputs.contains($0) ?? false)
}
for attr in protoOpDesc.attrs {
if (attr.type != .block) {
attrs[attr.name] = attrWithProtoDesc(attrDesc: attr)
}
}
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
public struct Program {
let paramPath: String
let programDesc: ProgramDesc
let scope: Scope
init(protoProgramDesc: PaddleMobile_Framework_Proto_ProgramDesc, inParamPath: String, inScope: Scope) {
programDesc = ProgramDesc.init(protoProgram: protoProgramDesc)
paramPath = inParamPath
scope = inScope
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
public struct ProgramDesc {
var blocks: [BlockDesc] = []
init(protoProgram: PaddleMobile_Framework_Proto_ProgramDesc) {
for block in protoProgram.blocks {
self.blocks.append(BlockDesc.init(block: block))
}
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
class Scope {
var vars: [String : Variant] = [:]
subscript(key: String) -> Variant?{
return vars[key]
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
struct TensorDesc {
let dims: [Int]
let dataType: VarTypeType
init(protoTensorDesc: PaddleMobile_Framework_Proto_VarType.TensorDesc) {
dims = protoTensorDesc.dims.map{ Int($0)}
dataType = VarTypeType.init(rawValue: protoTensorDesc.dataType.rawValue) ?? .ErrorType
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
enum VarTypeType: Int {
case ErrorType = -1,
Bool = 0,
Int16 = 1,
Int32 = 2,
Int64 = 3,
FP16 = 4,
FP32 = 5,
FP64 = 6,
LodTensor = 7,
SelectedRows = 8,
FeedMiniBatch = 9,
FetchList = 10,
StepScopes = 11,
StepLodRankTable = 12,
StepLodTensorArray = 13,
StepPlaceList = 14,
Reader = 15,
Channel = 16,
Raw = 17,
Tuple = 18
func dataTypeSize() throws -> Int {
switch self {
case .FP16:
return 2
case .FP32:
return 4
case .FP64:
return 8
case .Int32:
return 4
case .Int64:
return 8
case .Bool:
return 1
default:
throw PaddleMobileError.memoryError(message: "not support \(self) type to get size ")
}
}
}
struct VarDesc {
let name: String
let persistable: Bool
let type: VarTypeType
let tensorDesc: TensorDesc?
init(protoVarDesc: PaddleMobile_Framework_Proto_VarDesc) {
type = VarTypeType.init(rawValue: protoVarDesc.type.type.rawValue) ?? .ErrorType
name = protoVarDesc.name
persistable = protoVarDesc.persistable
switch type {
case .SelectedRows:
tensorDesc = TensorDesc.init(protoTensorDesc: protoVarDesc.type.selectedRows)
case .LodTensor:
tensorDesc = TensorDesc.init(protoTensorDesc: protoVarDesc.type.lodTensor.tensor)
case .StepLodTensorArray:
tensorDesc = TensorDesc.init(protoTensorDesc: protoVarDesc.type.tensorArray.tensor);
default:
tensorDesc = .none
}
}
}
// DO NOT EDIT.
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: framework.proto
//
// For information on using the generated types, please see the documenation:
// https://github.com/apple/swift-protobuf/
// Copyright (c) 2016 PaddlePaddle Authors. 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
import SwiftProtobuf
// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that your are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
typealias Version = _2
}
enum PaddleMobile_Framework_Proto_AttrType: SwiftProtobuf.Enum {
typealias RawValue = Int
case int // = 0
case float // = 1
case string // = 2
case ints // = 3
case floats // = 4
case strings // = 5
case boolean // = 6
case booleans // = 7
case block // = 8
case long // = 9
init() {
self = .int
}
init?(rawValue: Int) {
switch rawValue {
case 0: self = .int
case 1: self = .float
case 2: self = .string
case 3: self = .ints
case 4: self = .floats
case 5: self = .strings
case 6: self = .boolean
case 7: self = .booleans
case 8: self = .block
case 9: self = .long
default: return nil
}
}
var rawValue: Int {
switch self {
case .int: return 0
case .float: return 1
case .string: return 2
case .ints: return 3
case .floats: return 4
case .strings: return 5
case .boolean: return 6
case .booleans: return 7
case .block: return 8
case .long: return 9
}
}
}
/// OpDesc describes an instance of a C++ framework::OperatorBase
/// derived class type.
struct PaddleMobile_Framework_Proto_OpDesc {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var type: String {
get {return _type ?? String()}
set {_type = newValue}
}
/// Returns true if `type` has been explicitly set.
var hasType: Bool {return self._type != nil}
/// Clears the value of `type`. Subsequent reads from it will return its default value.
mutating func clearType() {self._type = nil}
var inputs: [PaddleMobile_Framework_Proto_OpDesc.Var] = []
var outputs: [PaddleMobile_Framework_Proto_OpDesc.Var] = []
var attrs: [PaddleMobile_Framework_Proto_OpDesc.Attr] = []
var isTarget: Bool {
get {return _isTarget ?? false}
set {_isTarget = newValue}
}
/// Returns true if `isTarget` has been explicitly set.
var hasIsTarget: Bool {return self._isTarget != nil}
/// Clears the value of `isTarget`. Subsequent reads from it will return its default value.
mutating func clearIsTarget() {self._isTarget = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
struct Attr {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var name: String {
get {return _name ?? String()}
set {_name = newValue}
}
/// Returns true if `name` has been explicitly set.
var hasName: Bool {return self._name != nil}
/// Clears the value of `name`. Subsequent reads from it will return its default value.
mutating func clearName() {self._name = nil}
var type: PaddleMobile_Framework_Proto_AttrType {
get {return _type ?? .int}
set {_type = newValue}
}
/// Returns true if `type` has been explicitly set.
var hasType: Bool {return self._type != nil}
/// Clears the value of `type`. Subsequent reads from it will return its default value.
mutating func clearType() {self._type = nil}
var i: Int32 {
get {return _i ?? 0}
set {_i = newValue}
}
/// Returns true if `i` has been explicitly set.
var hasI: Bool {return self._i != nil}
/// Clears the value of `i`. Subsequent reads from it will return its default value.
mutating func clearI() {self._i = nil}
var f: Float {
get {return _f ?? 0}
set {_f = newValue}
}
/// Returns true if `f` has been explicitly set.
var hasF: Bool {return self._f != nil}
/// Clears the value of `f`. Subsequent reads from it will return its default value.
mutating func clearF() {self._f = nil}
var s: String {
get {return _s ?? String()}
set {_s = newValue}
}
/// Returns true if `s` has been explicitly set.
var hasS: Bool {return self._s != nil}
/// Clears the value of `s`. Subsequent reads from it will return its default value.
mutating func clearS() {self._s = nil}
var ints: [Int32] = []
var floats: [Float] = []
var strings: [String] = []
var b: Bool {
get {return _b ?? false}
set {_b = newValue}
}
/// Returns true if `b` has been explicitly set.
var hasB: Bool {return self._b != nil}
/// Clears the value of `b`. Subsequent reads from it will return its default value.
mutating func clearB() {self._b = nil}
var bools: [Bool] = []
var blockIdx: Int32 {
get {return _blockIdx ?? 0}
set {_blockIdx = newValue}
}
/// Returns true if `blockIdx` has been explicitly set.
var hasBlockIdx: Bool {return self._blockIdx != nil}
/// Clears the value of `blockIdx`. Subsequent reads from it will return its default value.
mutating func clearBlockIdx() {self._blockIdx = nil}
var l: Int64 {
get {return _l ?? 0}
set {_l = newValue}
}
/// Returns true if `l` has been explicitly set.
var hasL: Bool {return self._l != nil}
/// Clears the value of `l`. Subsequent reads from it will return its default value.
mutating func clearL() {self._l = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _name: String? = nil
fileprivate var _type: PaddleMobile_Framework_Proto_AttrType? = nil
fileprivate var _i: Int32? = nil
fileprivate var _f: Float? = nil
fileprivate var _s: String? = nil
fileprivate var _b: Bool? = nil
fileprivate var _blockIdx: Int32? = nil
fileprivate var _l: Int64? = nil
}
struct Var {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var parameter: String {
get {return _parameter ?? String()}
set {_parameter = newValue}
}
/// Returns true if `parameter` has been explicitly set.
var hasParameter: Bool {return self._parameter != nil}
/// Clears the value of `parameter`. Subsequent reads from it will return its default value.
mutating func clearParameter() {self._parameter = nil}
var arguments: [String] = []
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _parameter: String? = nil
}
init() {}
fileprivate var _type: String? = nil
fileprivate var _isTarget: Bool? = nil
}
/// OpProto describes a C++ framework::OperatorBase derived class.
struct PaddleMobile_Framework_Proto_OpProto {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var type: String {
get {return _type ?? String()}
set {_type = newValue}
}
/// Returns true if `type` has been explicitly set.
var hasType: Bool {return self._type != nil}
/// Clears the value of `type`. Subsequent reads from it will return its default value.
mutating func clearType() {self._type = nil}
var inputs: [PaddleMobile_Framework_Proto_OpProto.Var] = []
var outputs: [PaddleMobile_Framework_Proto_OpProto.Var] = []
var attrs: [PaddleMobile_Framework_Proto_OpProto.Attr] = []
var comment: String {
get {return _comment ?? String()}
set {_comment = newValue}
}
/// Returns true if `comment` has been explicitly set.
var hasComment: Bool {return self._comment != nil}
/// Clears the value of `comment`. Subsequent reads from it will return its default value.
mutating func clearComment() {self._comment = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
/// VarProto describes the C++ type framework::Variable.
struct Var {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var name: String {
get {return _name ?? String()}
set {_name = newValue}
}
/// Returns true if `name` has been explicitly set.
var hasName: Bool {return self._name != nil}
/// Clears the value of `name`. Subsequent reads from it will return its default value.
mutating func clearName() {self._name = nil}
var comment: String {
get {return _comment ?? String()}
set {_comment = newValue}
}
/// Returns true if `comment` has been explicitly set.
var hasComment: Bool {return self._comment != nil}
/// Clears the value of `comment`. Subsequent reads from it will return its default value.
mutating func clearComment() {self._comment = nil}
var duplicable: Bool {
get {return _duplicable ?? false}
set {_duplicable = newValue}
}
/// Returns true if `duplicable` has been explicitly set.
var hasDuplicable: Bool {return self._duplicable != nil}
/// Clears the value of `duplicable`. Subsequent reads from it will return its default value.
mutating func clearDuplicable() {self._duplicable = nil}
var intermediate: Bool {
get {return _intermediate ?? false}
set {_intermediate = newValue}
}
/// Returns true if `intermediate` has been explicitly set.
var hasIntermediate: Bool {return self._intermediate != nil}
/// Clears the value of `intermediate`. Subsequent reads from it will return its default value.
mutating func clearIntermediate() {self._intermediate = nil}
var dispensable: Bool {
get {return _dispensable ?? false}
set {_dispensable = newValue}
}
/// Returns true if `dispensable` has been explicitly set.
var hasDispensable: Bool {return self._dispensable != nil}
/// Clears the value of `dispensable`. Subsequent reads from it will return its default value.
mutating func clearDispensable() {self._dispensable = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _name: String? = nil
fileprivate var _comment: String? = nil
fileprivate var _duplicable: Bool? = nil
fileprivate var _intermediate: Bool? = nil
fileprivate var _dispensable: Bool? = nil
}
/// AttrProto describes the C++ type Attribute.
struct Attr {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var name: String {
get {return _name ?? String()}
set {_name = newValue}
}
/// Returns true if `name` has been explicitly set.
var hasName: Bool {return self._name != nil}
/// Clears the value of `name`. Subsequent reads from it will return its default value.
mutating func clearName() {self._name = nil}
var type: PaddleMobile_Framework_Proto_AttrType {
get {return _type ?? .int}
set {_type = newValue}
}
/// Returns true if `type` has been explicitly set.
var hasType: Bool {return self._type != nil}
/// Clears the value of `type`. Subsequent reads from it will return its default value.
mutating func clearType() {self._type = nil}
var comment: String {
get {return _comment ?? String()}
set {_comment = newValue}
}
/// Returns true if `comment` has been explicitly set.
var hasComment: Bool {return self._comment != nil}
/// Clears the value of `comment`. Subsequent reads from it will return its default value.
mutating func clearComment() {self._comment = nil}
/// If that attribute is generated, it means the Paddle third
/// language binding has responsibility to fill that
/// attribute. End-User should not set that attribute.
var generated: Bool {
get {return _generated ?? false}
set {_generated = newValue}
}
/// Returns true if `generated` has been explicitly set.
var hasGenerated: Bool {return self._generated != nil}
/// Clears the value of `generated`. Subsequent reads from it will return its default value.
mutating func clearGenerated() {self._generated = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _name: String? = nil
fileprivate var _type: PaddleMobile_Framework_Proto_AttrType? = nil
fileprivate var _comment: String? = nil
fileprivate var _generated: Bool? = nil
}
init() {}
fileprivate var _type: String? = nil
fileprivate var _comment: String? = nil
}
struct PaddleMobile_Framework_Proto_VarType {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var type: PaddleMobile_Framework_Proto_VarType.TypeEnum {
get {return _storage._type ?? .bool}
set {_uniqueStorage()._type = newValue}
}
/// Returns true if `type` has been explicitly set.
var hasType: Bool {return _storage._type != nil}
/// Clears the value of `type`. Subsequent reads from it will return its default value.
mutating func clearType() {_storage._type = nil}
var selectedRows: PaddleMobile_Framework_Proto_VarType.TensorDesc {
get {return _storage._selectedRows ?? PaddleMobile_Framework_Proto_VarType.TensorDesc()}
set {_uniqueStorage()._selectedRows = newValue}
}
/// Returns true if `selectedRows` has been explicitly set.
var hasSelectedRows: Bool {return _storage._selectedRows != nil}
/// Clears the value of `selectedRows`. Subsequent reads from it will return its default value.
mutating func clearSelectedRows() {_storage._selectedRows = nil}
var lodTensor: PaddleMobile_Framework_Proto_VarType.LoDTensorDesc {
get {return _storage._lodTensor ?? PaddleMobile_Framework_Proto_VarType.LoDTensorDesc()}
set {_uniqueStorage()._lodTensor = newValue}
}
/// Returns true if `lodTensor` has been explicitly set.
var hasLodTensor: Bool {return _storage._lodTensor != nil}
/// Clears the value of `lodTensor`. Subsequent reads from it will return its default value.
mutating func clearLodTensor() {_storage._lodTensor = nil}
var tensorArray: PaddleMobile_Framework_Proto_VarType.LoDTensorArrayDesc {
get {return _storage._tensorArray ?? PaddleMobile_Framework_Proto_VarType.LoDTensorArrayDesc()}
set {_uniqueStorage()._tensorArray = newValue}
}
/// Returns true if `tensorArray` has been explicitly set.
var hasTensorArray: Bool {return _storage._tensorArray != nil}
/// Clears the value of `tensorArray`. Subsequent reads from it will return its default value.
mutating func clearTensorArray() {_storage._tensorArray = nil}
var reader: PaddleMobile_Framework_Proto_VarType.ReaderDesc {
get {return _storage._reader ?? PaddleMobile_Framework_Proto_VarType.ReaderDesc()}
set {_uniqueStorage()._reader = newValue}
}
/// Returns true if `reader` has been explicitly set.
var hasReader: Bool {return _storage._reader != nil}
/// Clears the value of `reader`. Subsequent reads from it will return its default value.
mutating func clearReader() {_storage._reader = nil}
var channel: PaddleMobile_Framework_Proto_VarType.ChannelDesc {
get {return _storage._channel ?? PaddleMobile_Framework_Proto_VarType.ChannelDesc()}
set {_uniqueStorage()._channel = newValue}
}
/// Returns true if `channel` has been explicitly set.
var hasChannel: Bool {return _storage._channel != nil}
/// Clears the value of `channel`. Subsequent reads from it will return its default value.
mutating func clearChannel() {_storage._channel = nil}
var tuple: PaddleMobile_Framework_Proto_VarType.Tuple {
get {return _storage._tuple ?? PaddleMobile_Framework_Proto_VarType.Tuple()}
set {_uniqueStorage()._tuple = newValue}
}
/// Returns true if `tuple` has been explicitly set.
var hasTuple: Bool {return _storage._tuple != nil}
/// Clears the value of `tuple`. Subsequent reads from it will return its default value.
mutating func clearTuple() {_storage._tuple = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
enum TypeEnum: SwiftProtobuf.Enum {
typealias RawValue = Int
/// Pod Types
case bool // = 0
case int16 // = 1
case int32 // = 2
case int64 // = 3
case fp16 // = 4
case fp32 // = 5
case fp64 // = 6
/// Other types that may need additional descriptions
case lodTensor // = 7
case selectedRows // = 8
case feedMinibatch // = 9
case fetchList // = 10
case stepScopes // = 11
case lodRankTable // = 12
case lodTensorArray // = 13
case placeList // = 14
case reader // = 15
case channel // = 16
/// Any runtime decided variable type is raw
/// raw variables should manage their own allocations
/// in operators like nccl_op
case raw // = 17
case tuple // = 18
init() {
self = .bool
}
init?(rawValue: Int) {
switch rawValue {
case 0: self = .bool
case 1: self = .int16
case 2: self = .int32
case 3: self = .int64
case 4: self = .fp16
case 5: self = .fp32
case 6: self = .fp64
case 7: self = .lodTensor
case 8: self = .selectedRows
case 9: self = .feedMinibatch
case 10: self = .fetchList
case 11: self = .stepScopes
case 12: self = .lodRankTable
case 13: self = .lodTensorArray
case 14: self = .placeList
case 15: self = .reader
case 16: self = .channel
case 17: self = .raw
case 18: self = .tuple
default: return nil
}
}
var rawValue: Int {
switch self {
case .bool: return 0
case .int16: return 1
case .int32: return 2
case .int64: return 3
case .fp16: return 4
case .fp32: return 5
case .fp64: return 6
case .lodTensor: return 7
case .selectedRows: return 8
case .feedMinibatch: return 9
case .fetchList: return 10
case .stepScopes: return 11
case .lodRankTable: return 12
case .lodTensorArray: return 13
case .placeList: return 14
case .reader: return 15
case .channel: return 16
case .raw: return 17
case .tuple: return 18
}
}
}
struct TensorDesc {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
/// Should only be PODType. Is enforced in C++
var dataType: PaddleMobile_Framework_Proto_VarType.TypeEnum {
get {return _dataType ?? .bool}
set {_dataType = newValue}
}
/// Returns true if `dataType` has been explicitly set.
var hasDataType: Bool {return self._dataType != nil}
/// Clears the value of `dataType`. Subsequent reads from it will return its default value.
mutating func clearDataType() {self._dataType = nil}
/// [UNK, 640, 480] is saved as [-1, 640, 480]
var dims: [Int64] = []
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _dataType: PaddleMobile_Framework_Proto_VarType.TypeEnum? = nil
}
struct LoDTensorDesc {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var tensor: PaddleMobile_Framework_Proto_VarType.TensorDesc {
get {return _storage._tensor ?? PaddleMobile_Framework_Proto_VarType.TensorDesc()}
set {_uniqueStorage()._tensor = newValue}
}
/// Returns true if `tensor` has been explicitly set.
var hasTensor: Bool {return _storage._tensor != nil}
/// Clears the value of `tensor`. Subsequent reads from it will return its default value.
mutating func clearTensor() {_storage._tensor = nil}
var lodLevel: Int32 {
get {return _storage._lodLevel ?? 0}
set {_uniqueStorage()._lodLevel = newValue}
}
/// Returns true if `lodLevel` has been explicitly set.
var hasLodLevel: Bool {return _storage._lodLevel != nil}
/// Clears the value of `lodLevel`. Subsequent reads from it will return its default value.
mutating func clearLodLevel() {_storage._lodLevel = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _storage = _StorageClass.defaultInstance
}
struct LoDTensorArrayDesc {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var tensor: PaddleMobile_Framework_Proto_VarType.TensorDesc {
get {return _storage._tensor ?? PaddleMobile_Framework_Proto_VarType.TensorDesc()}
set {_uniqueStorage()._tensor = newValue}
}
/// Returns true if `tensor` has been explicitly set.
var hasTensor: Bool {return _storage._tensor != nil}
/// Clears the value of `tensor`. Subsequent reads from it will return its default value.
mutating func clearTensor() {_storage._tensor = nil}
var lodLevel: Int32 {
get {return _storage._lodLevel ?? 0}
set {_uniqueStorage()._lodLevel = newValue}
}
/// Returns true if `lodLevel` has been explicitly set.
var hasLodLevel: Bool {return _storage._lodLevel != nil}
/// Clears the value of `lodLevel`. Subsequent reads from it will return its default value.
mutating func clearLodLevel() {_storage._lodLevel = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _storage = _StorageClass.defaultInstance
}
struct ReaderDesc {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var lodTensor: [PaddleMobile_Framework_Proto_VarType.LoDTensorDesc] = []
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
}
struct ChannelDesc {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var dataType: PaddleMobile_Framework_Proto_VarType.TypeEnum {
get {return _dataType ?? .bool}
set {_dataType = newValue}
}
/// Returns true if `dataType` has been explicitly set.
var hasDataType: Bool {return self._dataType != nil}
/// Clears the value of `dataType`. Subsequent reads from it will return its default value.
mutating func clearDataType() {self._dataType = nil}
var capacity: Int64 {
get {return _capacity ?? 0}
set {_capacity = newValue}
}
/// Returns true if `capacity` has been explicitly set.
var hasCapacity: Bool {return self._capacity != nil}
/// Clears the value of `capacity`. Subsequent reads from it will return its default value.
mutating func clearCapacity() {self._capacity = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _dataType: PaddleMobile_Framework_Proto_VarType.TypeEnum? = nil
fileprivate var _capacity: Int64? = nil
}
struct Tuple {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var elementType: [PaddleMobile_Framework_Proto_VarType.TypeEnum] = []
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
}
init() {}
fileprivate var _storage = _StorageClass.defaultInstance
}
struct PaddleMobile_Framework_Proto_VarDesc {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var name: String {
get {return _storage._name ?? String()}
set {_uniqueStorage()._name = newValue}
}
/// Returns true if `name` has been explicitly set.
var hasName: Bool {return _storage._name != nil}
/// Clears the value of `name`. Subsequent reads from it will return its default value.
mutating func clearName() {_storage._name = nil}
var type: PaddleMobile_Framework_Proto_VarType {
get {return _storage._type ?? PaddleMobile_Framework_Proto_VarType()}
set {_uniqueStorage()._type = newValue}
}
/// Returns true if `type` has been explicitly set.
var hasType: Bool {return _storage._type != nil}
/// Clears the value of `type`. Subsequent reads from it will return its default value.
mutating func clearType() {_storage._type = nil}
var persistable: Bool {
get {return _storage._persistable ?? false}
set {_uniqueStorage()._persistable = newValue}
}
/// Returns true if `persistable` has been explicitly set.
var hasPersistable: Bool {return _storage._persistable != nil}
/// Clears the value of `persistable`. Subsequent reads from it will return its default value.
mutating func clearPersistable() {_storage._persistable = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _storage = _StorageClass.defaultInstance
}
struct PaddleMobile_Framework_Proto_BlockDesc {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var idx: Int32 {
get {return _idx ?? 0}
set {_idx = newValue}
}
/// Returns true if `idx` has been explicitly set.
var hasIdx: Bool {return self._idx != nil}
/// Clears the value of `idx`. Subsequent reads from it will return its default value.
mutating func clearIdx() {self._idx = nil}
var parentIdx: Int32 {
get {return _parentIdx ?? 0}
set {_parentIdx = newValue}
}
/// Returns true if `parentIdx` has been explicitly set.
var hasParentIdx: Bool {return self._parentIdx != nil}
/// Clears the value of `parentIdx`. Subsequent reads from it will return its default value.
mutating func clearParentIdx() {self._parentIdx = nil}
var vars: [PaddleMobile_Framework_Proto_VarDesc] = []
var ops: [PaddleMobile_Framework_Proto_OpDesc] = []
var forwardBlockIdx: Int32 {
get {return _forwardBlockIdx ?? -1}
set {_forwardBlockIdx = newValue}
}
/// Returns true if `forwardBlockIdx` has been explicitly set.
var hasForwardBlockIdx: Bool {return self._forwardBlockIdx != nil}
/// Clears the value of `forwardBlockIdx`. Subsequent reads from it will return its default value.
mutating func clearForwardBlockIdx() {self._forwardBlockIdx = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _idx: Int32? = nil
fileprivate var _parentIdx: Int32? = nil
fileprivate var _forwardBlockIdx: Int32? = nil
}
/// Please refer to
/// https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/program.md
/// for more details.
/// TODO(panyx0718): A model can have multiple programs. Need a
/// way to distinguish them. Maybe ID or name?
struct PaddleMobile_Framework_Proto_ProgramDesc {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
var blocks: [PaddleMobile_Framework_Proto_BlockDesc] = []
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
}
// MARK: - Code below here is support for the SwiftProtobuf runtime.
fileprivate let _protobuf_package = "paddle_mobile.framework.proto"
extension PaddleMobile_Framework_Proto_AttrType: SwiftProtobuf._ProtoNameProviding {
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
0: .same(proto: "INT"),
1: .same(proto: "FLOAT"),
2: .same(proto: "STRING"),
3: .same(proto: "INTS"),
4: .same(proto: "FLOATS"),
5: .same(proto: "STRINGS"),
6: .same(proto: "BOOLEAN"),
7: .same(proto: "BOOLEANS"),
8: .same(proto: "BLOCK"),
9: .same(proto: "LONG"),
]
}
extension PaddleMobile_Framework_Proto_OpDesc: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".OpDesc"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
3: .same(proto: "type"),
1: .same(proto: "inputs"),
2: .same(proto: "outputs"),
4: .same(proto: "attrs"),
5: .standard(proto: "is_target"),
]
public var isInitialized: Bool {
if self._type == nil {return false}
if !SwiftProtobuf.Internal.areAllInitialized(self.inputs) {return false}
if !SwiftProtobuf.Internal.areAllInitialized(self.outputs) {return false}
if !SwiftProtobuf.Internal.areAllInitialized(self.attrs) {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeRepeatedMessageField(value: &self.inputs)
case 2: try decoder.decodeRepeatedMessageField(value: &self.outputs)
case 3: try decoder.decodeSingularStringField(value: &self._type)
case 4: try decoder.decodeRepeatedMessageField(value: &self.attrs)
case 5: try decoder.decodeSingularBoolField(value: &self._isTarget)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if !self.inputs.isEmpty {
try visitor.visitRepeatedMessageField(value: self.inputs, fieldNumber: 1)
}
if !self.outputs.isEmpty {
try visitor.visitRepeatedMessageField(value: self.outputs, fieldNumber: 2)
}
if let v = self._type {
try visitor.visitSingularStringField(value: v, fieldNumber: 3)
}
if !self.attrs.isEmpty {
try visitor.visitRepeatedMessageField(value: self.attrs, fieldNumber: 4)
}
if let v = self._isTarget {
try visitor.visitSingularBoolField(value: v, fieldNumber: 5)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_OpDesc) -> Bool {
if self._type != other._type {return false}
if self.inputs != other.inputs {return false}
if self.outputs != other.outputs {return false}
if self.attrs != other.attrs {return false}
if self._isTarget != other._isTarget {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_OpDesc.Attr: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_OpDesc.protoMessageName + ".Attr"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "name"),
2: .same(proto: "type"),
3: .same(proto: "i"),
4: .same(proto: "f"),
5: .same(proto: "s"),
6: .same(proto: "ints"),
7: .same(proto: "floats"),
8: .same(proto: "strings"),
10: .same(proto: "b"),
11: .same(proto: "bools"),
12: .standard(proto: "block_idx"),
13: .same(proto: "l"),
]
public var isInitialized: Bool {
if self._name == nil {return false}
if self._type == nil {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularStringField(value: &self._name)
case 2: try decoder.decodeSingularEnumField(value: &self._type)
case 3: try decoder.decodeSingularInt32Field(value: &self._i)
case 4: try decoder.decodeSingularFloatField(value: &self._f)
case 5: try decoder.decodeSingularStringField(value: &self._s)
case 6: try decoder.decodeRepeatedInt32Field(value: &self.ints)
case 7: try decoder.decodeRepeatedFloatField(value: &self.floats)
case 8: try decoder.decodeRepeatedStringField(value: &self.strings)
case 10: try decoder.decodeSingularBoolField(value: &self._b)
case 11: try decoder.decodeRepeatedBoolField(value: &self.bools)
case 12: try decoder.decodeSingularInt32Field(value: &self._blockIdx)
case 13: try decoder.decodeSingularInt64Field(value: &self._l)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if let v = self._name {
try visitor.visitSingularStringField(value: v, fieldNumber: 1)
}
if let v = self._type {
try visitor.visitSingularEnumField(value: v, fieldNumber: 2)
}
if let v = self._i {
try visitor.visitSingularInt32Field(value: v, fieldNumber: 3)
}
if let v = self._f {
try visitor.visitSingularFloatField(value: v, fieldNumber: 4)
}
if let v = self._s {
try visitor.visitSingularStringField(value: v, fieldNumber: 5)
}
if !self.ints.isEmpty {
try visitor.visitRepeatedInt32Field(value: self.ints, fieldNumber: 6)
}
if !self.floats.isEmpty {
try visitor.visitRepeatedFloatField(value: self.floats, fieldNumber: 7)
}
if !self.strings.isEmpty {
try visitor.visitRepeatedStringField(value: self.strings, fieldNumber: 8)
}
if let v = self._b {
try visitor.visitSingularBoolField(value: v, fieldNumber: 10)
}
if !self.bools.isEmpty {
try visitor.visitRepeatedBoolField(value: self.bools, fieldNumber: 11)
}
if let v = self._blockIdx {
try visitor.visitSingularInt32Field(value: v, fieldNumber: 12)
}
if let v = self._l {
try visitor.visitSingularInt64Field(value: v, fieldNumber: 13)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_OpDesc.Attr) -> Bool {
if self._name != other._name {return false}
if self._type != other._type {return false}
if self._i != other._i {return false}
if self._f != other._f {return false}
if self._s != other._s {return false}
if self.ints != other.ints {return false}
if self.floats != other.floats {return false}
if self.strings != other.strings {return false}
if self._b != other._b {return false}
if self.bools != other.bools {return false}
if self._blockIdx != other._blockIdx {return false}
if self._l != other._l {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_OpDesc.Var: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_OpDesc.protoMessageName + ".Var"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "parameter"),
2: .same(proto: "arguments"),
]
public var isInitialized: Bool {
if self._parameter == nil {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularStringField(value: &self._parameter)
case 2: try decoder.decodeRepeatedStringField(value: &self.arguments)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if let v = self._parameter {
try visitor.visitSingularStringField(value: v, fieldNumber: 1)
}
if !self.arguments.isEmpty {
try visitor.visitRepeatedStringField(value: self.arguments, fieldNumber: 2)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_OpDesc.Var) -> Bool {
if self._parameter != other._parameter {return false}
if self.arguments != other.arguments {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_OpProto: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".OpProto"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "type"),
2: .same(proto: "inputs"),
3: .same(proto: "outputs"),
4: .same(proto: "attrs"),
5: .same(proto: "comment"),
]
public var isInitialized: Bool {
if self._type == nil {return false}
if self._comment == nil {return false}
if !SwiftProtobuf.Internal.areAllInitialized(self.inputs) {return false}
if !SwiftProtobuf.Internal.areAllInitialized(self.outputs) {return false}
if !SwiftProtobuf.Internal.areAllInitialized(self.attrs) {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularStringField(value: &self._type)
case 2: try decoder.decodeRepeatedMessageField(value: &self.inputs)
case 3: try decoder.decodeRepeatedMessageField(value: &self.outputs)
case 4: try decoder.decodeRepeatedMessageField(value: &self.attrs)
case 5: try decoder.decodeSingularStringField(value: &self._comment)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if let v = self._type {
try visitor.visitSingularStringField(value: v, fieldNumber: 1)
}
if !self.inputs.isEmpty {
try visitor.visitRepeatedMessageField(value: self.inputs, fieldNumber: 2)
}
if !self.outputs.isEmpty {
try visitor.visitRepeatedMessageField(value: self.outputs, fieldNumber: 3)
}
if !self.attrs.isEmpty {
try visitor.visitRepeatedMessageField(value: self.attrs, fieldNumber: 4)
}
if let v = self._comment {
try visitor.visitSingularStringField(value: v, fieldNumber: 5)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_OpProto) -> Bool {
if self._type != other._type {return false}
if self.inputs != other.inputs {return false}
if self.outputs != other.outputs {return false}
if self.attrs != other.attrs {return false}
if self._comment != other._comment {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_OpProto.Var: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_OpProto.protoMessageName + ".Var"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "name"),
2: .same(proto: "comment"),
3: .same(proto: "duplicable"),
4: .same(proto: "intermediate"),
5: .same(proto: "dispensable"),
]
public var isInitialized: Bool {
if self._name == nil {return false}
if self._comment == nil {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularStringField(value: &self._name)
case 2: try decoder.decodeSingularStringField(value: &self._comment)
case 3: try decoder.decodeSingularBoolField(value: &self._duplicable)
case 4: try decoder.decodeSingularBoolField(value: &self._intermediate)
case 5: try decoder.decodeSingularBoolField(value: &self._dispensable)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if let v = self._name {
try visitor.visitSingularStringField(value: v, fieldNumber: 1)
}
if let v = self._comment {
try visitor.visitSingularStringField(value: v, fieldNumber: 2)
}
if let v = self._duplicable {
try visitor.visitSingularBoolField(value: v, fieldNumber: 3)
}
if let v = self._intermediate {
try visitor.visitSingularBoolField(value: v, fieldNumber: 4)
}
if let v = self._dispensable {
try visitor.visitSingularBoolField(value: v, fieldNumber: 5)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_OpProto.Var) -> Bool {
if self._name != other._name {return false}
if self._comment != other._comment {return false}
if self._duplicable != other._duplicable {return false}
if self._intermediate != other._intermediate {return false}
if self._dispensable != other._dispensable {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_OpProto.Attr: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_OpProto.protoMessageName + ".Attr"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "name"),
2: .same(proto: "type"),
3: .same(proto: "comment"),
4: .same(proto: "generated"),
]
public var isInitialized: Bool {
if self._name == nil {return false}
if self._type == nil {return false}
if self._comment == nil {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularStringField(value: &self._name)
case 2: try decoder.decodeSingularEnumField(value: &self._type)
case 3: try decoder.decodeSingularStringField(value: &self._comment)
case 4: try decoder.decodeSingularBoolField(value: &self._generated)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if let v = self._name {
try visitor.visitSingularStringField(value: v, fieldNumber: 1)
}
if let v = self._type {
try visitor.visitSingularEnumField(value: v, fieldNumber: 2)
}
if let v = self._comment {
try visitor.visitSingularStringField(value: v, fieldNumber: 3)
}
if let v = self._generated {
try visitor.visitSingularBoolField(value: v, fieldNumber: 4)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_OpProto.Attr) -> Bool {
if self._name != other._name {return false}
if self._type != other._type {return false}
if self._comment != other._comment {return false}
if self._generated != other._generated {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_VarType: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".VarType"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "type"),
2: .standard(proto: "selected_rows"),
3: .standard(proto: "lod_tensor"),
4: .standard(proto: "tensor_array"),
5: .same(proto: "reader"),
6: .same(proto: "channel"),
7: .same(proto: "tuple"),
]
fileprivate class _StorageClass {
var _type: PaddleMobile_Framework_Proto_VarType.TypeEnum? = nil
var _selectedRows: PaddleMobile_Framework_Proto_VarType.TensorDesc? = nil
var _lodTensor: PaddleMobile_Framework_Proto_VarType.LoDTensorDesc? = nil
var _tensorArray: PaddleMobile_Framework_Proto_VarType.LoDTensorArrayDesc? = nil
var _reader: PaddleMobile_Framework_Proto_VarType.ReaderDesc? = nil
var _channel: PaddleMobile_Framework_Proto_VarType.ChannelDesc? = nil
var _tuple: PaddleMobile_Framework_Proto_VarType.Tuple? = nil
static let defaultInstance = _StorageClass()
private init() {}
init(copying source: _StorageClass) {
_type = source._type
_selectedRows = source._selectedRows
_lodTensor = source._lodTensor
_tensorArray = source._tensorArray
_reader = source._reader
_channel = source._channel
_tuple = source._tuple
}
}
fileprivate mutating func _uniqueStorage() -> _StorageClass {
if !isKnownUniquelyReferenced(&_storage) {
_storage = _StorageClass(copying: _storage)
}
return _storage
}
public var isInitialized: Bool {
return withExtendedLifetime(_storage) { (_storage: _StorageClass) in
if _storage._type == nil {return false}
if let v = _storage._selectedRows, !v.isInitialized {return false}
if let v = _storage._lodTensor, !v.isInitialized {return false}
if let v = _storage._tensorArray, !v.isInitialized {return false}
if let v = _storage._reader, !v.isInitialized {return false}
if let v = _storage._channel, !v.isInitialized {return false}
return true
}
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
_ = _uniqueStorage()
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularEnumField(value: &_storage._type)
case 2: try decoder.decodeSingularMessageField(value: &_storage._selectedRows)
case 3: try decoder.decodeSingularMessageField(value: &_storage._lodTensor)
case 4: try decoder.decodeSingularMessageField(value: &_storage._tensorArray)
case 5: try decoder.decodeSingularMessageField(value: &_storage._reader)
case 6: try decoder.decodeSingularMessageField(value: &_storage._channel)
case 7: try decoder.decodeSingularMessageField(value: &_storage._tuple)
default: break
}
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
if let v = _storage._type {
try visitor.visitSingularEnumField(value: v, fieldNumber: 1)
}
if let v = _storage._selectedRows {
try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
}
if let v = _storage._lodTensor {
try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
}
if let v = _storage._tensorArray {
try visitor.visitSingularMessageField(value: v, fieldNumber: 4)
}
if let v = _storage._reader {
try visitor.visitSingularMessageField(value: v, fieldNumber: 5)
}
if let v = _storage._channel {
try visitor.visitSingularMessageField(value: v, fieldNumber: 6)
}
if let v = _storage._tuple {
try visitor.visitSingularMessageField(value: v, fieldNumber: 7)
}
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_VarType) -> Bool {
if _storage !== other._storage {
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
let _storage = _args.0
let other_storage = _args.1
if _storage._type != other_storage._type {return false}
if _storage._selectedRows != other_storage._selectedRows {return false}
if _storage._lodTensor != other_storage._lodTensor {return false}
if _storage._tensorArray != other_storage._tensorArray {return false}
if _storage._reader != other_storage._reader {return false}
if _storage._channel != other_storage._channel {return false}
if _storage._tuple != other_storage._tuple {return false}
return true
}
if !storagesAreEqual {return false}
}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_VarType.TypeEnum: SwiftProtobuf._ProtoNameProviding {
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
0: .same(proto: "BOOL"),
1: .same(proto: "INT16"),
2: .same(proto: "INT32"),
3: .same(proto: "INT64"),
4: .same(proto: "FP16"),
5: .same(proto: "FP32"),
6: .same(proto: "FP64"),
7: .same(proto: "LOD_TENSOR"),
8: .same(proto: "SELECTED_ROWS"),
9: .same(proto: "FEED_MINIBATCH"),
10: .same(proto: "FETCH_LIST"),
11: .same(proto: "STEP_SCOPES"),
12: .same(proto: "LOD_RANK_TABLE"),
13: .same(proto: "LOD_TENSOR_ARRAY"),
14: .same(proto: "PLACE_LIST"),
15: .same(proto: "READER"),
16: .same(proto: "CHANNEL"),
17: .same(proto: "RAW"),
18: .same(proto: "TUPLE"),
]
}
extension PaddleMobile_Framework_Proto_VarType.TensorDesc: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_VarType.protoMessageName + ".TensorDesc"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .standard(proto: "data_type"),
2: .same(proto: "dims"),
]
public var isInitialized: Bool {
if self._dataType == nil {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularEnumField(value: &self._dataType)
case 2: try decoder.decodeRepeatedInt64Field(value: &self.dims)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if let v = self._dataType {
try visitor.visitSingularEnumField(value: v, fieldNumber: 1)
}
if !self.dims.isEmpty {
try visitor.visitRepeatedInt64Field(value: self.dims, fieldNumber: 2)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_VarType.TensorDesc) -> Bool {
if self._dataType != other._dataType {return false}
if self.dims != other.dims {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_VarType.LoDTensorDesc: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_VarType.protoMessageName + ".LoDTensorDesc"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "tensor"),
2: .standard(proto: "lod_level"),
]
fileprivate class _StorageClass {
var _tensor: PaddleMobile_Framework_Proto_VarType.TensorDesc? = nil
var _lodLevel: Int32? = nil
static let defaultInstance = _StorageClass()
private init() {}
init(copying source: _StorageClass) {
_tensor = source._tensor
_lodLevel = source._lodLevel
}
}
fileprivate mutating func _uniqueStorage() -> _StorageClass {
if !isKnownUniquelyReferenced(&_storage) {
_storage = _StorageClass(copying: _storage)
}
return _storage
}
public var isInitialized: Bool {
return withExtendedLifetime(_storage) { (_storage: _StorageClass) in
if _storage._tensor == nil {return false}
if let v = _storage._tensor, !v.isInitialized {return false}
return true
}
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
_ = _uniqueStorage()
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularMessageField(value: &_storage._tensor)
case 2: try decoder.decodeSingularInt32Field(value: &_storage._lodLevel)
default: break
}
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
if let v = _storage._tensor {
try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
}
if let v = _storage._lodLevel {
try visitor.visitSingularInt32Field(value: v, fieldNumber: 2)
}
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_VarType.LoDTensorDesc) -> Bool {
if _storage !== other._storage {
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
let _storage = _args.0
let other_storage = _args.1
if _storage._tensor != other_storage._tensor {return false}
if _storage._lodLevel != other_storage._lodLevel {return false}
return true
}
if !storagesAreEqual {return false}
}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_VarType.LoDTensorArrayDesc: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_VarType.protoMessageName + ".LoDTensorArrayDesc"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "tensor"),
2: .standard(proto: "lod_level"),
]
fileprivate class _StorageClass {
var _tensor: PaddleMobile_Framework_Proto_VarType.TensorDesc? = nil
var _lodLevel: Int32? = nil
static let defaultInstance = _StorageClass()
private init() {}
init(copying source: _StorageClass) {
_tensor = source._tensor
_lodLevel = source._lodLevel
}
}
fileprivate mutating func _uniqueStorage() -> _StorageClass {
if !isKnownUniquelyReferenced(&_storage) {
_storage = _StorageClass(copying: _storage)
}
return _storage
}
public var isInitialized: Bool {
return withExtendedLifetime(_storage) { (_storage: _StorageClass) in
if _storage._tensor == nil {return false}
if let v = _storage._tensor, !v.isInitialized {return false}
return true
}
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
_ = _uniqueStorage()
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularMessageField(value: &_storage._tensor)
case 2: try decoder.decodeSingularInt32Field(value: &_storage._lodLevel)
default: break
}
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
if let v = _storage._tensor {
try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
}
if let v = _storage._lodLevel {
try visitor.visitSingularInt32Field(value: v, fieldNumber: 2)
}
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_VarType.LoDTensorArrayDesc) -> Bool {
if _storage !== other._storage {
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
let _storage = _args.0
let other_storage = _args.1
if _storage._tensor != other_storage._tensor {return false}
if _storage._lodLevel != other_storage._lodLevel {return false}
return true
}
if !storagesAreEqual {return false}
}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_VarType.ReaderDesc: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_VarType.protoMessageName + ".ReaderDesc"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .standard(proto: "lod_tensor"),
]
public var isInitialized: Bool {
if !SwiftProtobuf.Internal.areAllInitialized(self.lodTensor) {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeRepeatedMessageField(value: &self.lodTensor)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if !self.lodTensor.isEmpty {
try visitor.visitRepeatedMessageField(value: self.lodTensor, fieldNumber: 1)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_VarType.ReaderDesc) -> Bool {
if self.lodTensor != other.lodTensor {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_VarType.ChannelDesc: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_VarType.protoMessageName + ".ChannelDesc"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .standard(proto: "data_type"),
2: .same(proto: "capacity"),
]
public var isInitialized: Bool {
if self._dataType == nil {return false}
if self._capacity == nil {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularEnumField(value: &self._dataType)
case 2: try decoder.decodeSingularInt64Field(value: &self._capacity)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if let v = self._dataType {
try visitor.visitSingularEnumField(value: v, fieldNumber: 1)
}
if let v = self._capacity {
try visitor.visitSingularInt64Field(value: v, fieldNumber: 2)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_VarType.ChannelDesc) -> Bool {
if self._dataType != other._dataType {return false}
if self._capacity != other._capacity {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_VarType.Tuple: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = PaddleMobile_Framework_Proto_VarType.protoMessageName + ".Tuple"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .standard(proto: "element_type"),
]
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeRepeatedEnumField(value: &self.elementType)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if !self.elementType.isEmpty {
try visitor.visitRepeatedEnumField(value: self.elementType, fieldNumber: 1)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_VarType.Tuple) -> Bool {
if self.elementType != other.elementType {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_VarDesc: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".VarDesc"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "name"),
2: .same(proto: "type"),
3: .same(proto: "persistable"),
]
fileprivate class _StorageClass {
var _name: String? = nil
var _type: PaddleMobile_Framework_Proto_VarType? = nil
var _persistable: Bool? = nil
static let defaultInstance = _StorageClass()
private init() {}
init(copying source: _StorageClass) {
_name = source._name
_type = source._type
_persistable = source._persistable
}
}
fileprivate mutating func _uniqueStorage() -> _StorageClass {
if !isKnownUniquelyReferenced(&_storage) {
_storage = _StorageClass(copying: _storage)
}
return _storage
}
public var isInitialized: Bool {
return withExtendedLifetime(_storage) { (_storage: _StorageClass) in
if _storage._name == nil {return false}
if _storage._type == nil {return false}
if let v = _storage._type, !v.isInitialized {return false}
return true
}
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
_ = _uniqueStorage()
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularStringField(value: &_storage._name)
case 2: try decoder.decodeSingularMessageField(value: &_storage._type)
case 3: try decoder.decodeSingularBoolField(value: &_storage._persistable)
default: break
}
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
if let v = _storage._name {
try visitor.visitSingularStringField(value: v, fieldNumber: 1)
}
if let v = _storage._type {
try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
}
if let v = _storage._persistable {
try visitor.visitSingularBoolField(value: v, fieldNumber: 3)
}
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_VarDesc) -> Bool {
if _storage !== other._storage {
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
let _storage = _args.0
let other_storage = _args.1
if _storage._name != other_storage._name {return false}
if _storage._type != other_storage._type {return false}
if _storage._persistable != other_storage._persistable {return false}
return true
}
if !storagesAreEqual {return false}
}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_BlockDesc: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".BlockDesc"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "idx"),
2: .standard(proto: "parent_idx"),
3: .same(proto: "vars"),
4: .same(proto: "ops"),
5: .standard(proto: "forward_block_idx"),
]
public var isInitialized: Bool {
if self._idx == nil {return false}
if self._parentIdx == nil {return false}
if !SwiftProtobuf.Internal.areAllInitialized(self.vars) {return false}
if !SwiftProtobuf.Internal.areAllInitialized(self.ops) {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularInt32Field(value: &self._idx)
case 2: try decoder.decodeSingularInt32Field(value: &self._parentIdx)
case 3: try decoder.decodeRepeatedMessageField(value: &self.vars)
case 4: try decoder.decodeRepeatedMessageField(value: &self.ops)
case 5: try decoder.decodeSingularInt32Field(value: &self._forwardBlockIdx)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if let v = self._idx {
try visitor.visitSingularInt32Field(value: v, fieldNumber: 1)
}
if let v = self._parentIdx {
try visitor.visitSingularInt32Field(value: v, fieldNumber: 2)
}
if !self.vars.isEmpty {
try visitor.visitRepeatedMessageField(value: self.vars, fieldNumber: 3)
}
if !self.ops.isEmpty {
try visitor.visitRepeatedMessageField(value: self.ops, fieldNumber: 4)
}
if let v = self._forwardBlockIdx {
try visitor.visitSingularInt32Field(value: v, fieldNumber: 5)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_BlockDesc) -> Bool {
if self._idx != other._idx {return false}
if self._parentIdx != other._parentIdx {return false}
if self.vars != other.vars {return false}
if self.ops != other.ops {return false}
if self._forwardBlockIdx != other._forwardBlockIdx {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
extension PaddleMobile_Framework_Proto_ProgramDesc: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".ProgramDesc"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "blocks"),
]
public var isInitialized: Bool {
if !SwiftProtobuf.Internal.areAllInitialized(self.blocks) {return false}
return true
}
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeRepeatedMessageField(value: &self.blocks)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if !self.blocks.isEmpty {
try visitor.visitRepeatedMessageField(value: self.blocks, fieldNumber: 1)
}
try unknownFields.traverse(visitor: &visitor)
}
func _protobuf_generated_isEqualTo(other: PaddleMobile_Framework_Proto_ProgramDesc) -> Bool {
if self.blocks != other.blocks {return false}
if unknownFields != other.unknownFields {return false}
return true
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
struct Dim {
init(inDim: [Int]) {
dims = inDim
}
mutating func swapeDimAt(index1: Int, index2: Int) {
dims.swapAt(index1, index2)
}
func cout() -> Int {
return dims.count
}
func numel() -> Int {
return dims.reduce(1) { $0 * $1 }
}
static func ==(left: Dim, right: Dim) -> Bool {
return left.dims == right.dims;
}
subscript(index: Int) -> Int {
return dims[index];
}
private var dims: [Int]
private init(){
fatalError()
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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
class Tensor <P: PrecisionType>{
var dim: Dim {
return paraData.dim
}
let paraData: ParamData<P>
init(inDimArray: [Int], inData: ParamData<P>) {
paraData = inData
}
init(inData: ParamData<P>) {
paraData = inData
}
func numel() -> Int {
return dim.numel()
}
func dataLayout() -> DataLayout {
return paraData.layout
}
}
/* Copyright (c) 2018 PaddlePaddle Authors. 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/UIKit.h>
//! Project version number for paddle_mobile.
FOUNDATION_EXPORT double paddle_mobileVersionNumber;
//! Project version string for paddle_mobile.
FOUNDATION_EXPORT const unsigned char paddle_mobileVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <paddle_mobile/PublicHeader.h>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册