diff --git a/.gitignore b/.gitignore index c74d9ded6030d772cad5ccd05589a44e35db1054..40930e93627c15e436dddef384746163ebf71176 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ *.lai *.la *.lib +*.a # Executables *.exe diff --git a/metal/PreluKernel/PreluKernel.xcodeproj/project.pbxproj b/metal/PreluKernel/PreluKernel.xcodeproj/project.pbxproj deleted file mode 100644 index 76f0abb36b0129ce1553816def0548fb514f2876..0000000000000000000000000000000000000000 --- a/metal/PreluKernel/PreluKernel.xcodeproj/project.pbxproj +++ /dev/null @@ -1,164 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - FCEB6843212F00CC00D2448E /* PreluKernel.metal in Sources */ = {isa = PBXBuildFile; fileRef = FCEB6842212F00CC00D2448E /* PreluKernel.metal */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - FCEB683F212F00CC00D2448E /* PreluKernel.metallib */ = {isa = PBXFileReference; explicitFileType = "archive.metal-library"; includeInIndex = 0; path = PreluKernel.metallib; sourceTree = BUILT_PRODUCTS_DIR; }; - FCEB6842212F00CC00D2448E /* PreluKernel.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = PreluKernel.metal; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXGroup section */ - FCEB6838212F00CC00D2448E = { - isa = PBXGroup; - children = ( - FCEB6841212F00CC00D2448E /* PreluKernel */, - FCEB6840212F00CC00D2448E /* Products */, - ); - sourceTree = ""; - }; - FCEB6840212F00CC00D2448E /* Products */ = { - isa = PBXGroup; - children = ( - FCEB683F212F00CC00D2448E /* PreluKernel.metallib */, - ); - name = Products; - sourceTree = ""; - }; - FCEB6841212F00CC00D2448E /* PreluKernel */ = { - isa = PBXGroup; - children = ( - FCEB6842212F00CC00D2448E /* PreluKernel.metal */, - ); - path = PreluKernel; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - FCEB683E212F00CC00D2448E /* PreluKernel */ = { - isa = PBXNativeTarget; - buildConfigurationList = FCEB6846212F00CC00D2448E /* Build configuration list for PBXNativeTarget "PreluKernel" */; - buildPhases = ( - FCEB683D212F00CC00D2448E /* Sources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = PreluKernel; - productName = PreluKernel; - productReference = FCEB683F212F00CC00D2448E /* PreluKernel.metallib */; - productType = "com.apple.product-type.metal-library"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - FCEB6839212F00CC00D2448E /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0940; - ORGANIZATIONNAME = orange; - TargetAttributes = { - FCEB683E212F00CC00D2448E = { - CreatedOnToolsVersion = 9.4.1; - }; - }; - }; - buildConfigurationList = FCEB683C212F00CC00D2448E /* Build configuration list for PBXProject "PreluKernel" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = FCEB6838212F00CC00D2448E; - productRefGroup = FCEB6840212F00CC00D2448E /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - FCEB683E212F00CC00D2448E /* PreluKernel */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - FCEB683D212F00CC00D2448E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - FCEB6843212F00CC00D2448E /* PreluKernel.metal in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - FCEB6844212F00CC00D2448E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - IPHONEOS_DEPLOYMENT_TARGET = 11.4; - MTL_ENABLE_DEBUG_INFO = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - FCEB6845212F00CC00D2448E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - IPHONEOS_DEPLOYMENT_TARGET = 11.4; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - }; - name = Release; - }; - FCEB6847212F00CC00D2448E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Z5M2UUN5YV; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - FCEB6848212F00CC00D2448E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Z5M2UUN5YV; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - FCEB683C212F00CC00D2448E /* Build configuration list for PBXProject "PreluKernel" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - FCEB6844212F00CC00D2448E /* Debug */, - FCEB6845212F00CC00D2448E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - FCEB6846212F00CC00D2448E /* Build configuration list for PBXNativeTarget "PreluKernel" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - FCEB6847212F00CC00D2448E /* Debug */, - FCEB6848212F00CC00D2448E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = FCEB6839212F00CC00D2448E /* Project object */; -} diff --git a/metal/PreluKernel/PreluKernel.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/metal/PreluKernel/PreluKernel.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index bb481babbf9c954edbc2d32efb8eb41c70beb21c..0000000000000000000000000000000000000000 --- a/metal/PreluKernel/PreluKernel.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/metal/PreluKernel/PreluKernel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/metal/PreluKernel/PreluKernel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003d68d0546c4804ac2ff47dd97c6e7921..0000000000000000000000000000000000000000 --- a/metal/PreluKernel/PreluKernel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/metal/PreluKernel/PreluKernel.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/xcschememanagement.plist b/metal/PreluKernel/PreluKernel.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 803d380b4d56c2270f2370cc5a1670b428d73793..0000000000000000000000000000000000000000 --- a/metal/PreluKernel/PreluKernel.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,14 +0,0 @@ - - - - - SchemeUserState - - PreluKernel.xcscheme - - orderHint - 0 - - - - diff --git a/metal/PreluKernel/PreluKernel/PreluKernel.metal b/metal/PreluKernel/PreluKernel/PreluKernel.metal deleted file mode 100644 index 7aa5e72ba9249ffe19152a9583ff103837d83f0b..0000000000000000000000000000000000000000 --- a/metal/PreluKernel/PreluKernel/PreluKernel.metal +++ /dev/null @@ -1,12 +0,0 @@ -// -// PreluKernel.metal -// PreluKernel -// -// Created by liuRuiLong on 2018/8/23. -// Copyright © 2018年 orange. All rights reserved. -// - -#include -using namespace metal; - - diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj index f70555ea7e5af9f078cfd825ad7e227077346367..b4e8dae35f692c91c765d0e77c0d7841b48a2414 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj +++ b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj @@ -8,234 +8,31 @@ /* Begin PBXBuildFile section */ 30D0ED21F392CFA3885B1002 /* Pods_paddle_mobile_demo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18896810981724F8A0FED62A /* Pods_paddle_mobile_demo.framework */; }; - C23717882148E5A50092444E /* ar_model in Resources */ = {isa = PBXBuildFile; fileRef = C23717862148E5A50092444E /* ar_model */; }; - C23717892148E5A50092444E /* ar_params in Resources */ = {isa = PBXBuildFile; fileRef = C23717872148E5A50092444E /* ar_params */; }; - C2C08E3B2142748D00C69DBF /* synset.txt in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D5B2142748D00C69DBF /* synset.txt */; }; - C2C08E3C2142748D00C69DBF /* banana.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D5C2142748D00C69DBF /* banana.jpeg */; }; - C2C08E3D2142748D00C69DBF /* hand.jpg in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D5D2142748D00C69DBF /* hand.jpg */; }; - C2C08E3E2142748D00C69DBF /* iphone.JPG in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D5E2142748D00C69DBF /* iphone.JPG */; }; - C2C08E3F2142748D00C69DBF /* paddle-mobile.png in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D5F2142748D00C69DBF /* paddle-mobile.png */; }; - C2C08E402142748D00C69DBF /* params in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D622142748D00C69DBF /* params */; }; - C2C08E412142748D00C69DBF /* model in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D632142748D00C69DBF /* model */; }; - C2C08E422142748D00C69DBF /* genet_params in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D652142748D00C69DBF /* genet_params */; }; - C2C08E432142748D00C69DBF /* genet_model in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D662142748D00C69DBF /* genet_model */; }; - C2C08E442142748D00C69DBF /* ssd_hand_params in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D682142748D00C69DBF /* ssd_hand_params */; }; - C2C08E452142748D00C69DBF /* ssd_hand_model in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D692142748D00C69DBF /* ssd_hand_model */; }; - C2C08E462142748D00C69DBF /* mobilenet in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D6B2142748D00C69DBF /* mobilenet */; }; - C2C08E472142748D00C69DBF /* params in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D6C2142748D00C69DBF /* params */; }; - C2C08E482142748D00C69DBF /* model in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D6D2142748D00C69DBF /* model */; }; - C2C08E492142748D00C69DBF /* yolo in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D6E2142748D00C69DBF /* yolo */; }; - C2C08E4A2142748D00C69DBF /* params in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D702142748D00C69DBF /* params */; }; - C2C08E4B2142748D00C69DBF /* model in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D712142748D00C69DBF /* model */; }; - C2C08E4C2142748D00C69DBF /* batch_norm_7.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D732142748D00C69DBF /* batch_norm_7.w_0 */; }; - C2C08E4D2142748D00C69DBF /* batch_norm_26.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D742142748D00C69DBF /* batch_norm_26.b_0 */; }; - C2C08E4E2142748D00C69DBF /* batch_norm_32.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D752142748D00C69DBF /* batch_norm_32.b_0 */; }; - C2C08E4F2142748D00C69DBF /* conv2d_16.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D762142748D00C69DBF /* conv2d_16.w_0 */; }; - C2C08E502142748D00C69DBF /* batch_norm_15.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D772142748D00C69DBF /* batch_norm_15.w_2 */; }; - C2C08E512142748D00C69DBF /* batch_norm_29.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D782142748D00C69DBF /* batch_norm_29.w_2 */; }; - C2C08E522142748D00C69DBF /* batch_norm_4.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D792142748D00C69DBF /* batch_norm_4.w_1 */; }; - C2C08E532142748D00C69DBF /* batch_norm_5.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D7A2142748D00C69DBF /* batch_norm_5.w_1 */; }; - C2C08E542142748D00C69DBF /* batch_norm_28.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D7B2142748D00C69DBF /* batch_norm_28.w_2 */; }; - C2C08E552142748D00C69DBF /* batch_norm_14.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D7C2142748D00C69DBF /* batch_norm_14.w_2 */; }; - C2C08E562142748D00C69DBF /* conv2d_17.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D7D2142748D00C69DBF /* conv2d_17.w_0 */; }; - C2C08E572142748D00C69DBF /* batch_norm_33.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D7E2142748D00C69DBF /* batch_norm_33.b_0 */; }; - C2C08E582142748D00C69DBF /* batch_norm_27.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D7F2142748D00C69DBF /* batch_norm_27.b_0 */; }; - C2C08E592142748D00C69DBF /* batch_norm_6.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D802142748D00C69DBF /* batch_norm_6.w_0 */; }; - C2C08E5A2142748D00C69DBF /* batch_norm_4.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D812142748D00C69DBF /* batch_norm_4.w_0 */; }; - C2C08E5B2142748D00C69DBF /* depthwise_conv2d_9.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D822142748D00C69DBF /* depthwise_conv2d_9.w_0 */; }; - C2C08E5C2142748D00C69DBF /* batch_norm_31.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D832142748D00C69DBF /* batch_norm_31.b_0 */; }; - C2C08E5D2142748D00C69DBF /* conv2d_29.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D842142748D00C69DBF /* conv2d_29.w_0 */; }; - C2C08E5E2142748D00C69DBF /* batch_norm_25.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D852142748D00C69DBF /* batch_norm_25.b_0 */; }; - C2C08E5F2142748D00C69DBF /* conv2d_15.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D862142748D00C69DBF /* conv2d_15.w_0 */; }; - C2C08E602142748D00C69DBF /* batch_norm_19.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D872142748D00C69DBF /* batch_norm_19.b_0 */; }; - C2C08E612142748D00C69DBF /* batch_norm_16.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D882142748D00C69DBF /* batch_norm_16.w_2 */; }; - C2C08E622142748D00C69DBF /* __model__ in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D892142748D00C69DBF /* __model__ */; }; - C2C08E632142748D00C69DBF /* batch_norm_7.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D8A2142748D00C69DBF /* batch_norm_7.w_1 */; }; - C2C08E642142748D00C69DBF /* batch_norm_6.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D8B2142748D00C69DBF /* batch_norm_6.w_1 */; }; - C2C08E652142748D00C69DBF /* batch_norm_17.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D8C2142748D00C69DBF /* batch_norm_17.w_2 */; }; - C2C08E662142748D00C69DBF /* conv2d_14.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D8D2142748D00C69DBF /* conv2d_14.w_0 */; }; - C2C08E672142748D00C69DBF /* batch_norm_18.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D8E2142748D00C69DBF /* batch_norm_18.b_0 */; }; - C2C08E682142748D00C69DBF /* conv2d_28.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D8F2142748D00C69DBF /* conv2d_28.w_0 */; }; - C2C08E692142748D00C69DBF /* batch_norm_24.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D902142748D00C69DBF /* batch_norm_24.b_0 */; }; - C2C08E6A2142748D00C69DBF /* batch_norm_30.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D912142748D00C69DBF /* batch_norm_30.b_0 */; }; - C2C08E6B2142748D00C69DBF /* depthwise_conv2d_8.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D922142748D00C69DBF /* depthwise_conv2d_8.w_0 */; }; - C2C08E6C2142748D00C69DBF /* batch_norm_5.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D932142748D00C69DBF /* batch_norm_5.w_0 */; }; - C2C08E6D2142748D00C69DBF /* batch_norm_1.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D942142748D00C69DBF /* batch_norm_1.w_0 */; }; - C2C08E6E2142748D00C69DBF /* conv2d_10.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D952142748D00C69DBF /* conv2d_10.w_0 */; }; - C2C08E6F2142748D00C69DBF /* batch_norm_34.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D962142748D00C69DBF /* batch_norm_34.b_0 */; }; - C2C08E702142748D00C69DBF /* batch_norm_20.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D972142748D00C69DBF /* batch_norm_20.b_0 */; }; - C2C08E712142748D00C69DBF /* batch_norm_13.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D982142748D00C69DBF /* batch_norm_13.w_2 */; }; - C2C08E722142748D00C69DBF /* batch_norm_2.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D992142748D00C69DBF /* batch_norm_2.w_1 */; }; - C2C08E732142748D00C69DBF /* batch_norm_3.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D9A2142748D00C69DBF /* batch_norm_3.w_1 */; }; - C2C08E742142748D00C69DBF /* batch_norm_12.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D9B2142748D00C69DBF /* batch_norm_12.w_2 */; }; - C2C08E752142748D00C69DBF /* batch_norm_21.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D9C2142748D00C69DBF /* batch_norm_21.b_0 */; }; - C2C08E762142748D00C69DBF /* conv2d_11.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D9D2142748D00C69DBF /* conv2d_11.w_0 */; }; - C2C08E772142748D00C69DBF /* batch_norm_0.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D9E2142748D00C69DBF /* batch_norm_0.w_0 */; }; - C2C08E782142748D00C69DBF /* batch_norm_2.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08D9F2142748D00C69DBF /* batch_norm_2.w_0 */; }; - C2C08E792142748D00C69DBF /* conv2d_13.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA02142748D00C69DBF /* conv2d_13.w_0 */; }; - C2C08E7A2142748D00C69DBF /* batch_norm_23.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA12142748D00C69DBF /* batch_norm_23.b_0 */; }; - C2C08E7B2142748D00C69DBF /* batch_norm_10.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA22142748D00C69DBF /* batch_norm_10.w_2 */; }; - C2C08E7C2142748D00C69DBF /* batch_norm_1.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA32142748D00C69DBF /* batch_norm_1.w_1 */; }; - C2C08E7D2142748D00C69DBF /* batch_norm_0.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA42142748D00C69DBF /* batch_norm_0.w_1 */; }; - C2C08E7E2142748D00C69DBF /* batch_norm_11.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA52142748D00C69DBF /* batch_norm_11.w_2 */; }; - C2C08E7F2142748D00C69DBF /* batch_norm_22.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA62142748D00C69DBF /* batch_norm_22.b_0 */; }; - C2C08E802142748D00C69DBF /* conv2d_12.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA72142748D00C69DBF /* conv2d_12.w_0 */; }; - C2C08E812142748D00C69DBF /* batch_norm_3.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA82142748D00C69DBF /* batch_norm_3.w_0 */; }; - C2C08E822142748D00C69DBF /* batch_norm_21.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DA92142748D00C69DBF /* batch_norm_21.w_1 */; }; - C2C08E832142748D00C69DBF /* batch_norm_3.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DAA2142748D00C69DBF /* batch_norm_3.b_0 */; }; - C2C08E842142748D00C69DBF /* batch_norm_22.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DAB2142748D00C69DBF /* batch_norm_22.w_0 */; }; - C2C08E852142748D00C69DBF /* batch_norm_23.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DAC2142748D00C69DBF /* batch_norm_23.w_0 */; }; - C2C08E862142748D00C69DBF /* batch_norm_2.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DAD2142748D00C69DBF /* batch_norm_2.b_0 */; }; - C2C08E872142748D00C69DBF /* batch_norm_20.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DAE2142748D00C69DBF /* batch_norm_20.w_1 */; }; - C2C08E882142748D00C69DBF /* batch_norm_34.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DAF2142748D00C69DBF /* batch_norm_34.w_1 */; }; - C2C08E892142748D00C69DBF /* batch_norm_22.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB02142748D00C69DBF /* batch_norm_22.w_1 */; }; - C2C08E8A2142748D00C69DBF /* batch_norm_0.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB12142748D00C69DBF /* batch_norm_0.b_0 */; }; - C2C08E8B2142748D00C69DBF /* batch_norm_21.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB22142748D00C69DBF /* batch_norm_21.w_0 */; }; - C2C08E8C2142748D00C69DBF /* batch_norm_20.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB32142748D00C69DBF /* batch_norm_20.w_0 */; }; - C2C08E8D2142748D00C69DBF /* batch_norm_34.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB42142748D00C69DBF /* batch_norm_34.w_0 */; }; - C2C08E8E2142748D00C69DBF /* batch_norm_1.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB52142748D00C69DBF /* batch_norm_1.b_0 */; }; - C2C08E8F2142748D00C69DBF /* batch_norm_23.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB62142748D00C69DBF /* batch_norm_23.w_1 */; }; - C2C08E902142748D00C69DBF /* batch_norm_27.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB72142748D00C69DBF /* batch_norm_27.w_1 */; }; - C2C08E912142748D00C69DBF /* batch_norm_33.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB82142748D00C69DBF /* batch_norm_33.w_1 */; }; - C2C08E922142748D00C69DBF /* batch_norm_5.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DB92142748D00C69DBF /* batch_norm_5.b_0 */; }; - C2C08E932142748D00C69DBF /* batch_norm_18.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DBA2142748D00C69DBF /* batch_norm_18.w_0 */; }; - C2C08E942142748D00C69DBF /* batch_norm_30.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DBB2142748D00C69DBF /* batch_norm_30.w_0 */; }; - C2C08E952142748D00C69DBF /* batch_norm_24.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DBC2142748D00C69DBF /* batch_norm_24.w_0 */; }; - C2C08E962142748D00C69DBF /* conv2d_28.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DBD2142748D00C69DBF /* conv2d_28.b_0 */; }; - C2C08E972142748D00C69DBF /* batch_norm_25.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DBE2142748D00C69DBF /* batch_norm_25.w_0 */; }; - C2C08E982142748D00C69DBF /* conv2d_29.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DBF2142748D00C69DBF /* conv2d_29.b_0 */; }; - C2C08E992142748D00C69DBF /* batch_norm_31.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC02142748D00C69DBF /* batch_norm_31.w_0 */; }; - C2C08E9A2142748D00C69DBF /* batch_norm_19.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC12142748D00C69DBF /* batch_norm_19.w_0 */; }; - C2C08E9B2142748D00C69DBF /* batch_norm_4.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC22142748D00C69DBF /* batch_norm_4.b_0 */; }; - C2C08E9C2142748D00C69DBF /* batch_norm_32.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC32142748D00C69DBF /* batch_norm_32.w_1 */; }; - C2C08E9D2142748D00C69DBF /* batch_norm_26.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC42142748D00C69DBF /* batch_norm_26.w_1 */; }; - C2C08E9E2142748D00C69DBF /* batch_norm_30.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC52142748D00C69DBF /* batch_norm_30.w_1 */; }; - C2C08E9F2142748D00C69DBF /* batch_norm_24.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC62142748D00C69DBF /* batch_norm_24.w_1 */; }; - C2C08EA02142748D00C69DBF /* batch_norm_18.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC72142748D00C69DBF /* batch_norm_18.w_1 */; }; - C2C08EA12142748D00C69DBF /* batch_norm_6.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC82142748D00C69DBF /* batch_norm_6.b_0 */; }; - C2C08EA22142748D00C69DBF /* batch_norm_9.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DC92142748D00C69DBF /* batch_norm_9.w_2 */; }; - C2C08EA32142748D00C69DBF /* conv2d_8.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DCA2142748D00C69DBF /* conv2d_8.w_0 */; }; - C2C08EA42142748D00C69DBF /* batch_norm_27.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DCB2142748D00C69DBF /* batch_norm_27.w_0 */; }; - C2C08EA52142748D00C69DBF /* batch_norm_33.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DCC2142748D00C69DBF /* batch_norm_33.w_0 */; }; - C2C08EA62142748D00C69DBF /* batch_norm_32.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DCD2142748D00C69DBF /* batch_norm_32.w_0 */; }; - C2C08EA72142748D00C69DBF /* conv2d_9.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DCE2142748D00C69DBF /* conv2d_9.w_0 */; }; - C2C08EA82142748D00C69DBF /* batch_norm_26.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DCF2142748D00C69DBF /* batch_norm_26.w_0 */; }; - C2C08EA92142748D00C69DBF /* batch_norm_8.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD02142748D00C69DBF /* batch_norm_8.w_2 */; }; - C2C08EAA2142748D00C69DBF /* batch_norm_7.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD12142748D00C69DBF /* batch_norm_7.b_0 */; }; - C2C08EAB2142748D00C69DBF /* batch_norm_19.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD22142748D00C69DBF /* batch_norm_19.w_1 */; }; - C2C08EAC2142748D00C69DBF /* batch_norm_25.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD32142748D00C69DBF /* batch_norm_25.w_1 */; }; - C2C08EAD2142748D00C69DBF /* batch_norm_31.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD42142748D00C69DBF /* batch_norm_31.w_1 */; }; - C2C08EAE2142748D00C69DBF /* batch_norm_28.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD52142748D00C69DBF /* batch_norm_28.w_1 */; }; - C2C08EAF2142748D00C69DBF /* batch_norm_14.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD62142748D00C69DBF /* batch_norm_14.w_1 */; }; - C2C08EB02142748D00C69DBF /* batch_norm_5.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD72142748D00C69DBF /* batch_norm_5.w_2 */; }; - C2C08EB12142748D00C69DBF /* batch_norm_17.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD82142748D00C69DBF /* batch_norm_17.w_0 */; }; - C2C08EB22142748D00C69DBF /* conv2d_33.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DD92142748D00C69DBF /* conv2d_33.b_0 */; }; - C2C08EB32142748D00C69DBF /* conv2d_27.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DDA2142748D00C69DBF /* conv2d_27.b_0 */; }; - C2C08EB42142748D00C69DBF /* conv2d_4.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DDB2142748D00C69DBF /* conv2d_4.w_0 */; }; - C2C08EB52142748D00C69DBF /* conv2d_5.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DDC2142748D00C69DBF /* conv2d_5.w_0 */; }; - C2C08EB62142748D00C69DBF /* conv2d_26.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DDD2142748D00C69DBF /* conv2d_26.b_0 */; }; - C2C08EB72142748D00C69DBF /* conv2d_32.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DDE2142748D00C69DBF /* conv2d_32.b_0 */; }; - C2C08EB82142748D00C69DBF /* batch_norm_16.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DDF2142748D00C69DBF /* batch_norm_16.w_0 */; }; - C2C08EB92142748D00C69DBF /* batch_norm_4.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE02142748D00C69DBF /* batch_norm_4.w_2 */; }; - C2C08EBA2142748D00C69DBF /* batch_norm_15.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE12142748D00C69DBF /* batch_norm_15.w_1 */; }; - C2C08EBB2142748D00C69DBF /* batch_norm_29.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE22142748D00C69DBF /* batch_norm_29.w_1 */; }; - C2C08EBC2142748D00C69DBF /* batch_norm_17.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE32142748D00C69DBF /* batch_norm_17.w_1 */; }; - C2C08EBD2142748D00C69DBF /* batch_norm_9.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE42142748D00C69DBF /* batch_norm_9.b_0 */; }; - C2C08EBE2142748D00C69DBF /* batch_norm_6.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE52142748D00C69DBF /* batch_norm_6.w_2 */; }; - C2C08EBF2142748D00C69DBF /* batch_norm_14.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE62142748D00C69DBF /* batch_norm_14.w_0 */; }; - C2C08EC02142748D00C69DBF /* batch_norm_28.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE72142748D00C69DBF /* batch_norm_28.w_0 */; }; - C2C08EC12142748D00C69DBF /* conv2d_24.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE82142748D00C69DBF /* conv2d_24.b_0 */; }; - C2C08EC22142748D00C69DBF /* conv2d_7.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DE92142748D00C69DBF /* conv2d_7.w_0 */; }; - C2C08EC32142748D00C69DBF /* conv2d_30.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DEA2142748D00C69DBF /* conv2d_30.b_0 */; }; - C2C08EC42142748D00C69DBF /* conv2d_31.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DEB2142748D00C69DBF /* conv2d_31.b_0 */; }; - C2C08EC52142748D00C69DBF /* batch_norm_29.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DEC2142748D00C69DBF /* batch_norm_29.w_0 */; }; - C2C08EC62142748D00C69DBF /* conv2d_6.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DED2142748D00C69DBF /* conv2d_6.w_0 */; }; - C2C08EC72142748D00C69DBF /* conv2d_25.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DEE2142748D00C69DBF /* conv2d_25.b_0 */; }; - C2C08EC82142748D00C69DBF /* batch_norm_15.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DEF2142748D00C69DBF /* batch_norm_15.w_0 */; }; - C2C08EC92142748D00C69DBF /* batch_norm_7.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF02142748D00C69DBF /* batch_norm_7.w_2 */; }; - C2C08ECA2142748D00C69DBF /* batch_norm_8.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF12142748D00C69DBF /* batch_norm_8.b_0 */; }; - C2C08ECB2142748D00C69DBF /* batch_norm_16.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF22142748D00C69DBF /* batch_norm_16.w_1 */; }; - C2C08ECC2142748D00C69DBF /* batch_norm_12.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF32142748D00C69DBF /* batch_norm_12.w_1 */; }; - C2C08ECD2142748D00C69DBF /* batch_norm_3.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF42142748D00C69DBF /* batch_norm_3.w_2 */; }; - C2C08ECE2142748D00C69DBF /* conv2d_2.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF52142748D00C69DBF /* conv2d_2.w_0 */; }; - C2C08ECF2142748D00C69DBF /* batch_norm_11.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF62142748D00C69DBF /* batch_norm_11.w_0 */; }; - C2C08ED02142748D00C69DBF /* batch_norm_10.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF72142748D00C69DBF /* batch_norm_10.w_0 */; }; - C2C08ED12142748D00C69DBF /* conv2d_3.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF82142748D00C69DBF /* conv2d_3.w_0 */; }; - C2C08ED22142748D00C69DBF /* batch_norm_2.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DF92142748D00C69DBF /* batch_norm_2.w_2 */; }; - C2C08ED32142748D00C69DBF /* depthwise_conv2d_12.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DFA2142748D00C69DBF /* depthwise_conv2d_12.w_0 */; }; - C2C08ED42142748D00C69DBF /* batch_norm_13.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DFB2142748D00C69DBF /* batch_norm_13.w_1 */; }; - C2C08ED52142748D00C69DBF /* batch_norm_11.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DFC2142748D00C69DBF /* batch_norm_11.w_1 */; }; - C2C08ED62142748D00C69DBF /* depthwise_conv2d_10.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DFD2142748D00C69DBF /* depthwise_conv2d_10.w_0 */; }; - C2C08ED72142748D00C69DBF /* batch_norm_0.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DFE2142748D00C69DBF /* batch_norm_0.w_2 */; }; - C2C08ED82142748D00C69DBF /* conv2d_22.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08DFF2142748D00C69DBF /* conv2d_22.b_0 */; }; - C2C08ED92142748D00C69DBF /* conv2d_1.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E002142748D00C69DBF /* conv2d_1.w_0 */; }; - C2C08EDA2142748D00C69DBF /* batch_norm_12.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E012142748D00C69DBF /* batch_norm_12.w_0 */; }; - C2C08EDB2142748D00C69DBF /* batch_norm_13.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E022142748D00C69DBF /* batch_norm_13.w_0 */; }; - C2C08EDC2142748D00C69DBF /* conv2d_0.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E032142748D00C69DBF /* conv2d_0.w_0 */; }; - C2C08EDD2142748D00C69DBF /* conv2d_23.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E042142748D00C69DBF /* conv2d_23.b_0 */; }; - C2C08EDE2142748D00C69DBF /* batch_norm_1.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E052142748D00C69DBF /* batch_norm_1.w_2 */; }; - C2C08EDF2142748D00C69DBF /* batch_norm_10.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E062142748D00C69DBF /* batch_norm_10.w_1 */; }; - C2C08EE02142748D00C69DBF /* depthwise_conv2d_11.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E072142748D00C69DBF /* depthwise_conv2d_11.w_0 */; }; - C2C08EE12142748D00C69DBF /* depthwise_conv2d_3.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E082142748D00C69DBF /* depthwise_conv2d_3.w_0 */; }; - C2C08EE22142748D00C69DBF /* batch_norm_13.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E092142748D00C69DBF /* batch_norm_13.b_0 */; }; - C2C08EE32142748D00C69DBF /* conv2d_23.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E0A2142748D00C69DBF /* conv2d_23.w_0 */; }; - C2C08EE42142748D00C69DBF /* batch_norm_20.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E0B2142748D00C69DBF /* batch_norm_20.w_2 */; }; - C2C08EE52142748D00C69DBF /* batch_norm_34.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E0C2142748D00C69DBF /* batch_norm_34.w_2 */; }; - C2C08EE62142748D00C69DBF /* batch_norm_21.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E0D2142748D00C69DBF /* batch_norm_21.w_2 */; }; - C2C08EE72142748D00C69DBF /* conv2d_22.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E0E2142748D00C69DBF /* conv2d_22.w_0 */; }; - C2C08EE82142748D00C69DBF /* batch_norm_12.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E0F2142748D00C69DBF /* batch_norm_12.b_0 */; }; - C2C08EE92142748D00C69DBF /* depthwise_conv2d_2.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E102142748D00C69DBF /* depthwise_conv2d_2.w_0 */; }; - C2C08EEA2142748D00C69DBF /* depthwise_conv2d_0.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E112142748D00C69DBF /* depthwise_conv2d_0.w_0 */; }; - C2C08EEB2142748D00C69DBF /* batch_norm_10.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E122142748D00C69DBF /* batch_norm_10.b_0 */; }; - C2C08EEC2142748D00C69DBF /* conv2d_20.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E132142748D00C69DBF /* conv2d_20.w_0 */; }; - C2C08EED2142748D00C69DBF /* batch_norm_23.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E142142748D00C69DBF /* batch_norm_23.w_2 */; }; - C2C08EEE2142748D00C69DBF /* batch_norm_22.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E152142748D00C69DBF /* batch_norm_22.w_2 */; }; - C2C08EEF2142748D00C69DBF /* conv2d_21.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E162142748D00C69DBF /* conv2d_21.w_0 */; }; - C2C08EF02142748D00C69DBF /* batch_norm_11.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E172142748D00C69DBF /* batch_norm_11.b_0 */; }; - C2C08EF12142748D00C69DBF /* depthwise_conv2d_1.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E182142748D00C69DBF /* depthwise_conv2d_1.w_0 */; }; - C2C08EF22142748D00C69DBF /* depthwise_conv2d_5.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E192142748D00C69DBF /* depthwise_conv2d_5.w_0 */; }; - C2C08EF32142748D00C69DBF /* batch_norm_8.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E1A2142748D00C69DBF /* batch_norm_8.w_0 */; }; - C2C08EF42142748D00C69DBF /* conv2d_25.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E1B2142748D00C69DBF /* conv2d_25.w_0 */; }; - C2C08EF52142748D00C69DBF /* batch_norm_29.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E1C2142748D00C69DBF /* batch_norm_29.b_0 */; }; - C2C08EF62142748D00C69DBF /* conv2d_31.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E1D2142748D00C69DBF /* conv2d_31.w_0 */; }; - C2C08EF72142748D00C69DBF /* conv2d_19.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E1E2142748D00C69DBF /* conv2d_19.w_0 */; }; - C2C08EF82142748D00C69DBF /* batch_norm_15.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E1F2142748D00C69DBF /* batch_norm_15.b_0 */; }; - C2C08EF92142748D00C69DBF /* batch_norm_32.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E202142748D00C69DBF /* batch_norm_32.w_2 */; }; - C2C08EFA2142748D00C69DBF /* batch_norm_26.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E212142748D00C69DBF /* batch_norm_26.w_2 */; }; - C2C08EFB2142748D00C69DBF /* batch_norm_27.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E222142748D00C69DBF /* batch_norm_27.w_2 */; }; - C2C08EFC2142748D00C69DBF /* batch_norm_33.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E232142748D00C69DBF /* batch_norm_33.w_2 */; }; - C2C08EFD2142748D00C69DBF /* conv2d_18.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E242142748D00C69DBF /* conv2d_18.w_0 */; }; - C2C08EFE2142748D00C69DBF /* batch_norm_14.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E252142748D00C69DBF /* batch_norm_14.b_0 */; }; - C2C08EFF2142748D00C69DBF /* conv2d_30.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E262142748D00C69DBF /* conv2d_30.w_0 */; }; - C2C08F002142748D00C69DBF /* conv2d_24.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E272142748D00C69DBF /* conv2d_24.w_0 */; }; - C2C08F012142748D00C69DBF /* batch_norm_28.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E282142748D00C69DBF /* batch_norm_28.b_0 */; }; - C2C08F022142748D00C69DBF /* batch_norm_9.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E292142748D00C69DBF /* batch_norm_9.w_0 */; }; - C2C08F032142748D00C69DBF /* depthwise_conv2d_4.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E2A2142748D00C69DBF /* depthwise_conv2d_4.w_0 */; }; - C2C08F042142748D00C69DBF /* depthwise_conv2d_6.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E2B2142748D00C69DBF /* depthwise_conv2d_6.w_0 */; }; - C2C08F052142748D00C69DBF /* conv2d_32.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E2C2142748D00C69DBF /* conv2d_32.w_0 */; }; - C2C08F062142748D00C69DBF /* conv2d_26.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E2D2142748D00C69DBF /* conv2d_26.w_0 */; }; - C2C08F072142748D00C69DBF /* batch_norm_16.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E2E2142748D00C69DBF /* batch_norm_16.b_0 */; }; - C2C08F082142748D00C69DBF /* batch_norm_19.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E2F2142748D00C69DBF /* batch_norm_19.w_2 */; }; - C2C08F092142748D00C69DBF /* batch_norm_25.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E302142748D00C69DBF /* batch_norm_25.w_2 */; }; - C2C08F0A2142748D00C69DBF /* batch_norm_31.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E312142748D00C69DBF /* batch_norm_31.w_2 */; }; - C2C08F0B2142748D00C69DBF /* batch_norm_8.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E322142748D00C69DBF /* batch_norm_8.w_1 */; }; - C2C08F0C2142748D00C69DBF /* batch_norm_9.w_1 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E332142748D00C69DBF /* batch_norm_9.w_1 */; }; - C2C08F0D2142748D00C69DBF /* batch_norm_30.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E342142748D00C69DBF /* batch_norm_30.w_2 */; }; - C2C08F0E2142748D00C69DBF /* batch_norm_24.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E352142748D00C69DBF /* batch_norm_24.w_2 */; }; - C2C08F0F2142748D00C69DBF /* batch_norm_18.w_2 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E362142748D00C69DBF /* batch_norm_18.w_2 */; }; - C2C08F102142748D00C69DBF /* batch_norm_17.b_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E372142748D00C69DBF /* batch_norm_17.b_0 */; }; - C2C08F112142748D00C69DBF /* conv2d_27.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E382142748D00C69DBF /* conv2d_27.w_0 */; }; - C2C08F122142748D00C69DBF /* conv2d_33.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E392142748D00C69DBF /* conv2d_33.w_0 */; }; - C2C08F132142748D00C69DBF /* depthwise_conv2d_7.w_0 in Resources */ = {isa = PBXBuildFile; fileRef = C2C08E3A2142748D00C69DBF /* depthwise_conv2d_7.w_0 */; }; FC013928210204A3008100E3 /* PreProcessKernel.metal in Sources */ = {isa = PBXBuildFile; fileRef = FC013927210204A3008100E3 /* PreProcessKernel.metal */; }; FC039B8220E11C550081E9F8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC039B8120E11C550081E9F8 /* AppDelegate.swift */; }; FC039B8420E11C550081E9F8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC039B8320E11C550081E9F8 /* ViewController.swift */; }; FC039B8720E11C550081E9F8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC039B8520E11C550081E9F8 /* Main.storyboard */; }; FC039B8920E11C560081E9F8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FC039B8820E11C560081E9F8 /* Assets.xcassets */; }; FC039B8C20E11C560081E9F8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC039B8A20E11C560081E9F8 /* LaunchScreen.storyboard */; }; + FC803BCD214D27930094B8E5 /* FPSCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC803BCB214D27920094B8E5 /* FPSCounter.swift */; }; + FC803BCE214D27930094B8E5 /* VideoCapture.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC803BCC214D27920094B8E5 /* VideoCapture.swift */; }; + FC8CFEE62135452C0094D569 /* genet_params in Resources */ = {isa = PBXBuildFile; fileRef = FC8CFEE42135452B0094D569 /* genet_params */; }; + FC8CFEE72135452C0094D569 /* genet_model in Resources */ = {isa = PBXBuildFile; fileRef = FC8CFEE52135452B0094D569 /* genet_model */; }; + FC8CFEF8213551D10094D569 /* params in Resources */ = {isa = PBXBuildFile; fileRef = FC8CFEF6213551D00094D569 /* params */; }; + FC8CFEF9213551D10094D569 /* model in Resources */ = {isa = PBXBuildFile; fileRef = FC8CFEF7213551D00094D569 /* model */; }; + FC918191211DBC3500B6F354 /* paddle-mobile.png in Resources */ = {isa = PBXBuildFile; fileRef = FC918190211DBC3500B6F354 /* paddle-mobile.png */; }; + FC918193211DC70500B6F354 /* iphone.JPG in Resources */ = {isa = PBXBuildFile; fileRef = FC918192211DC70500B6F354 /* iphone.JPG */; }; + FC9A19E72148C38400CD9CBF /* ar_model in Resources */ = {isa = PBXBuildFile; fileRef = FC9A19E52148C38400CD9CBF /* ar_model */; }; + FC9A19E82148C38400CD9CBF /* ar_params in Resources */ = {isa = PBXBuildFile; fileRef = FC9A19E62148C38400CD9CBF /* ar_params */; }; + FCA3A16121313E1F00084FE5 /* hand.jpg in Resources */ = {isa = PBXBuildFile; fileRef = FCA3A16021313E1F00084FE5 /* hand.jpg */; }; + FCBCCC522122EEDC00D94F7E /* ssd_hand_params in Resources */ = {isa = PBXBuildFile; fileRef = FCBCCC502122EEDC00D94F7E /* ssd_hand_params */; }; + FCBCCC532122EEDC00D94F7E /* ssd_hand_model in Resources */ = {isa = PBXBuildFile; fileRef = FCBCCC512122EEDC00D94F7E /* ssd_hand_model */; }; FCBCCC552122EF5500D94F7E /* MetalHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCBCCC542122EF5400D94F7E /* MetalHelper.swift */; }; + FCDFD41B211D91C7005AB38B /* synset.txt in Resources */ = {isa = PBXBuildFile; fileRef = FCDFD41A211D91C7005AB38B /* synset.txt */; }; FCEBEC2C20E1391F00C0B14D /* paddle_mobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */; }; FCEBEC2D20E1391F00C0B14D /* paddle_mobile.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + FCEEE7D4210627A000444BEC /* banana.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FCEEE7D3210627A000444BEC /* banana.jpeg */; }; + FCF437E8214B6DDB00943429 /* MultiPredictViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCF437E7214B6DDB00943429 /* MultiPredictViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -256,225 +53,6 @@ 081C9CF10DB06C58B8B6B039 /* Pods-paddle-mobile-demo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paddle-mobile-demo.release.xcconfig"; path = "../Pods/Target Support Files/Pods-paddle-mobile-demo/Pods-paddle-mobile-demo.release.xcconfig"; sourceTree = ""; }; 18896810981724F8A0FED62A /* Pods_paddle_mobile_demo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_paddle_mobile_demo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 878829884E1A14D7044721D5 /* Pods-paddle-mobile-demo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paddle-mobile-demo.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-paddle-mobile-demo/Pods-paddle-mobile-demo.debug.xcconfig"; sourceTree = ""; }; - C23717862148E5A50092444E /* ar_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = ar_model; sourceTree = ""; }; - C23717872148E5A50092444E /* ar_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = ar_params; sourceTree = ""; }; - C2C08D5B2142748D00C69DBF /* synset.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = synset.txt; sourceTree = ""; }; - C2C08D5C2142748D00C69DBF /* banana.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = banana.jpeg; sourceTree = ""; }; - C2C08D5D2142748D00C69DBF /* hand.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = hand.jpg; sourceTree = ""; }; - C2C08D5E2142748D00C69DBF /* iphone.JPG */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = iphone.JPG; sourceTree = ""; }; - C2C08D5F2142748D00C69DBF /* paddle-mobile.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "paddle-mobile.png"; sourceTree = ""; }; - C2C08D622142748D00C69DBF /* params */ = {isa = PBXFileReference; lastKnownFileType = file; path = params; sourceTree = ""; }; - C2C08D632142748D00C69DBF /* model */ = {isa = PBXFileReference; lastKnownFileType = file; path = model; sourceTree = ""; }; - C2C08D652142748D00C69DBF /* genet_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = genet_params; sourceTree = ""; }; - C2C08D662142748D00C69DBF /* genet_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = genet_model; sourceTree = ""; }; - C2C08D682142748D00C69DBF /* ssd_hand_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = ssd_hand_params; sourceTree = ""; }; - C2C08D692142748D00C69DBF /* ssd_hand_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = ssd_hand_model; sourceTree = ""; }; - C2C08D6B2142748D00C69DBF /* mobilenet */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mobilenet; sourceTree = ""; }; - C2C08D6C2142748D00C69DBF /* params */ = {isa = PBXFileReference; lastKnownFileType = file; path = params; sourceTree = ""; }; - C2C08D6D2142748D00C69DBF /* model */ = {isa = PBXFileReference; lastKnownFileType = file; path = model; sourceTree = ""; }; - C2C08D6E2142748D00C69DBF /* yolo */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = yolo; sourceTree = ""; }; - C2C08D702142748D00C69DBF /* params */ = {isa = PBXFileReference; lastKnownFileType = file; path = params; sourceTree = ""; }; - C2C08D712142748D00C69DBF /* model */ = {isa = PBXFileReference; lastKnownFileType = file; path = model; sourceTree = ""; }; - C2C08D732142748D00C69DBF /* batch_norm_7.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_7.w_0; sourceTree = ""; }; - C2C08D742142748D00C69DBF /* batch_norm_26.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_26.b_0; sourceTree = ""; }; - C2C08D752142748D00C69DBF /* batch_norm_32.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_32.b_0; sourceTree = ""; }; - C2C08D762142748D00C69DBF /* conv2d_16.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_16.w_0; sourceTree = ""; }; - C2C08D772142748D00C69DBF /* batch_norm_15.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_15.w_2; sourceTree = ""; }; - C2C08D782142748D00C69DBF /* batch_norm_29.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_29.w_2; sourceTree = ""; }; - C2C08D792142748D00C69DBF /* batch_norm_4.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_4.w_1; sourceTree = ""; }; - C2C08D7A2142748D00C69DBF /* batch_norm_5.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_5.w_1; sourceTree = ""; }; - C2C08D7B2142748D00C69DBF /* batch_norm_28.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_28.w_2; sourceTree = ""; }; - C2C08D7C2142748D00C69DBF /* batch_norm_14.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_14.w_2; sourceTree = ""; }; - C2C08D7D2142748D00C69DBF /* conv2d_17.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_17.w_0; sourceTree = ""; }; - C2C08D7E2142748D00C69DBF /* batch_norm_33.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_33.b_0; sourceTree = ""; }; - C2C08D7F2142748D00C69DBF /* batch_norm_27.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_27.b_0; sourceTree = ""; }; - C2C08D802142748D00C69DBF /* batch_norm_6.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_6.w_0; sourceTree = ""; }; - C2C08D812142748D00C69DBF /* batch_norm_4.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_4.w_0; sourceTree = ""; }; - C2C08D822142748D00C69DBF /* depthwise_conv2d_9.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_9.w_0; sourceTree = ""; }; - C2C08D832142748D00C69DBF /* batch_norm_31.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_31.b_0; sourceTree = ""; }; - C2C08D842142748D00C69DBF /* conv2d_29.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_29.w_0; sourceTree = ""; }; - C2C08D852142748D00C69DBF /* batch_norm_25.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_25.b_0; sourceTree = ""; }; - C2C08D862142748D00C69DBF /* conv2d_15.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_15.w_0; sourceTree = ""; }; - C2C08D872142748D00C69DBF /* batch_norm_19.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_19.b_0; sourceTree = ""; }; - C2C08D882142748D00C69DBF /* batch_norm_16.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_16.w_2; sourceTree = ""; }; - C2C08D892142748D00C69DBF /* __model__ */ = {isa = PBXFileReference; lastKnownFileType = file; path = __model__; sourceTree = ""; }; - C2C08D8A2142748D00C69DBF /* batch_norm_7.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_7.w_1; sourceTree = ""; }; - C2C08D8B2142748D00C69DBF /* batch_norm_6.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_6.w_1; sourceTree = ""; }; - C2C08D8C2142748D00C69DBF /* batch_norm_17.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_17.w_2; sourceTree = ""; }; - C2C08D8D2142748D00C69DBF /* conv2d_14.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_14.w_0; sourceTree = ""; }; - C2C08D8E2142748D00C69DBF /* batch_norm_18.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_18.b_0; sourceTree = ""; }; - C2C08D8F2142748D00C69DBF /* conv2d_28.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_28.w_0; sourceTree = ""; }; - C2C08D902142748D00C69DBF /* batch_norm_24.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_24.b_0; sourceTree = ""; }; - C2C08D912142748D00C69DBF /* batch_norm_30.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_30.b_0; sourceTree = ""; }; - C2C08D922142748D00C69DBF /* depthwise_conv2d_8.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_8.w_0; sourceTree = ""; }; - C2C08D932142748D00C69DBF /* batch_norm_5.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_5.w_0; sourceTree = ""; }; - C2C08D942142748D00C69DBF /* batch_norm_1.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_1.w_0; sourceTree = ""; }; - C2C08D952142748D00C69DBF /* conv2d_10.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_10.w_0; sourceTree = ""; }; - C2C08D962142748D00C69DBF /* batch_norm_34.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_34.b_0; sourceTree = ""; }; - C2C08D972142748D00C69DBF /* batch_norm_20.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_20.b_0; sourceTree = ""; }; - C2C08D982142748D00C69DBF /* batch_norm_13.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_13.w_2; sourceTree = ""; }; - C2C08D992142748D00C69DBF /* batch_norm_2.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_2.w_1; sourceTree = ""; }; - C2C08D9A2142748D00C69DBF /* batch_norm_3.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_3.w_1; sourceTree = ""; }; - C2C08D9B2142748D00C69DBF /* batch_norm_12.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_12.w_2; sourceTree = ""; }; - C2C08D9C2142748D00C69DBF /* batch_norm_21.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_21.b_0; sourceTree = ""; }; - C2C08D9D2142748D00C69DBF /* conv2d_11.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_11.w_0; sourceTree = ""; }; - C2C08D9E2142748D00C69DBF /* batch_norm_0.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_0.w_0; sourceTree = ""; }; - C2C08D9F2142748D00C69DBF /* batch_norm_2.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_2.w_0; sourceTree = ""; }; - C2C08DA02142748D00C69DBF /* conv2d_13.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_13.w_0; sourceTree = ""; }; - C2C08DA12142748D00C69DBF /* batch_norm_23.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_23.b_0; sourceTree = ""; }; - C2C08DA22142748D00C69DBF /* batch_norm_10.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_10.w_2; sourceTree = ""; }; - C2C08DA32142748D00C69DBF /* batch_norm_1.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_1.w_1; sourceTree = ""; }; - C2C08DA42142748D00C69DBF /* batch_norm_0.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_0.w_1; sourceTree = ""; }; - C2C08DA52142748D00C69DBF /* batch_norm_11.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_11.w_2; sourceTree = ""; }; - C2C08DA62142748D00C69DBF /* batch_norm_22.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_22.b_0; sourceTree = ""; }; - C2C08DA72142748D00C69DBF /* conv2d_12.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_12.w_0; sourceTree = ""; }; - C2C08DA82142748D00C69DBF /* batch_norm_3.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_3.w_0; sourceTree = ""; }; - C2C08DA92142748D00C69DBF /* batch_norm_21.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_21.w_1; sourceTree = ""; }; - C2C08DAA2142748D00C69DBF /* batch_norm_3.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_3.b_0; sourceTree = ""; }; - C2C08DAB2142748D00C69DBF /* batch_norm_22.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_22.w_0; sourceTree = ""; }; - C2C08DAC2142748D00C69DBF /* batch_norm_23.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_23.w_0; sourceTree = ""; }; - C2C08DAD2142748D00C69DBF /* batch_norm_2.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_2.b_0; sourceTree = ""; }; - C2C08DAE2142748D00C69DBF /* batch_norm_20.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_20.w_1; sourceTree = ""; }; - C2C08DAF2142748D00C69DBF /* batch_norm_34.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_34.w_1; sourceTree = ""; }; - C2C08DB02142748D00C69DBF /* batch_norm_22.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_22.w_1; sourceTree = ""; }; - C2C08DB12142748D00C69DBF /* batch_norm_0.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_0.b_0; sourceTree = ""; }; - C2C08DB22142748D00C69DBF /* batch_norm_21.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_21.w_0; sourceTree = ""; }; - C2C08DB32142748D00C69DBF /* batch_norm_20.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_20.w_0; sourceTree = ""; }; - C2C08DB42142748D00C69DBF /* batch_norm_34.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_34.w_0; sourceTree = ""; }; - C2C08DB52142748D00C69DBF /* batch_norm_1.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_1.b_0; sourceTree = ""; }; - C2C08DB62142748D00C69DBF /* batch_norm_23.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_23.w_1; sourceTree = ""; }; - C2C08DB72142748D00C69DBF /* batch_norm_27.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_27.w_1; sourceTree = ""; }; - C2C08DB82142748D00C69DBF /* batch_norm_33.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_33.w_1; sourceTree = ""; }; - C2C08DB92142748D00C69DBF /* batch_norm_5.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_5.b_0; sourceTree = ""; }; - C2C08DBA2142748D00C69DBF /* batch_norm_18.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_18.w_0; sourceTree = ""; }; - C2C08DBB2142748D00C69DBF /* batch_norm_30.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_30.w_0; sourceTree = ""; }; - C2C08DBC2142748D00C69DBF /* batch_norm_24.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_24.w_0; sourceTree = ""; }; - C2C08DBD2142748D00C69DBF /* conv2d_28.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_28.b_0; sourceTree = ""; }; - C2C08DBE2142748D00C69DBF /* batch_norm_25.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_25.w_0; sourceTree = ""; }; - C2C08DBF2142748D00C69DBF /* conv2d_29.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_29.b_0; sourceTree = ""; }; - C2C08DC02142748D00C69DBF /* batch_norm_31.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_31.w_0; sourceTree = ""; }; - C2C08DC12142748D00C69DBF /* batch_norm_19.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_19.w_0; sourceTree = ""; }; - C2C08DC22142748D00C69DBF /* batch_norm_4.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_4.b_0; sourceTree = ""; }; - C2C08DC32142748D00C69DBF /* batch_norm_32.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_32.w_1; sourceTree = ""; }; - C2C08DC42142748D00C69DBF /* batch_norm_26.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_26.w_1; sourceTree = ""; }; - C2C08DC52142748D00C69DBF /* batch_norm_30.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_30.w_1; sourceTree = ""; }; - C2C08DC62142748D00C69DBF /* batch_norm_24.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_24.w_1; sourceTree = ""; }; - C2C08DC72142748D00C69DBF /* batch_norm_18.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_18.w_1; sourceTree = ""; }; - C2C08DC82142748D00C69DBF /* batch_norm_6.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_6.b_0; sourceTree = ""; }; - C2C08DC92142748D00C69DBF /* batch_norm_9.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_9.w_2; sourceTree = ""; }; - C2C08DCA2142748D00C69DBF /* conv2d_8.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_8.w_0; sourceTree = ""; }; - C2C08DCB2142748D00C69DBF /* batch_norm_27.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_27.w_0; sourceTree = ""; }; - C2C08DCC2142748D00C69DBF /* batch_norm_33.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_33.w_0; sourceTree = ""; }; - C2C08DCD2142748D00C69DBF /* batch_norm_32.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_32.w_0; sourceTree = ""; }; - C2C08DCE2142748D00C69DBF /* conv2d_9.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_9.w_0; sourceTree = ""; }; - C2C08DCF2142748D00C69DBF /* batch_norm_26.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_26.w_0; sourceTree = ""; }; - C2C08DD02142748D00C69DBF /* batch_norm_8.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_8.w_2; sourceTree = ""; }; - C2C08DD12142748D00C69DBF /* batch_norm_7.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_7.b_0; sourceTree = ""; }; - C2C08DD22142748D00C69DBF /* batch_norm_19.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_19.w_1; sourceTree = ""; }; - C2C08DD32142748D00C69DBF /* batch_norm_25.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_25.w_1; sourceTree = ""; }; - C2C08DD42142748D00C69DBF /* batch_norm_31.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_31.w_1; sourceTree = ""; }; - C2C08DD52142748D00C69DBF /* batch_norm_28.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_28.w_1; sourceTree = ""; }; - C2C08DD62142748D00C69DBF /* batch_norm_14.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_14.w_1; sourceTree = ""; }; - C2C08DD72142748D00C69DBF /* batch_norm_5.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_5.w_2; sourceTree = ""; }; - C2C08DD82142748D00C69DBF /* batch_norm_17.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_17.w_0; sourceTree = ""; }; - C2C08DD92142748D00C69DBF /* conv2d_33.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_33.b_0; sourceTree = ""; }; - C2C08DDA2142748D00C69DBF /* conv2d_27.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_27.b_0; sourceTree = ""; }; - C2C08DDB2142748D00C69DBF /* conv2d_4.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_4.w_0; sourceTree = ""; }; - C2C08DDC2142748D00C69DBF /* conv2d_5.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_5.w_0; sourceTree = ""; }; - C2C08DDD2142748D00C69DBF /* conv2d_26.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_26.b_0; sourceTree = ""; }; - C2C08DDE2142748D00C69DBF /* conv2d_32.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_32.b_0; sourceTree = ""; }; - C2C08DDF2142748D00C69DBF /* batch_norm_16.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_16.w_0; sourceTree = ""; }; - C2C08DE02142748D00C69DBF /* batch_norm_4.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_4.w_2; sourceTree = ""; }; - C2C08DE12142748D00C69DBF /* batch_norm_15.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_15.w_1; sourceTree = ""; }; - C2C08DE22142748D00C69DBF /* batch_norm_29.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_29.w_1; sourceTree = ""; }; - C2C08DE32142748D00C69DBF /* batch_norm_17.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_17.w_1; sourceTree = ""; }; - C2C08DE42142748D00C69DBF /* batch_norm_9.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_9.b_0; sourceTree = ""; }; - C2C08DE52142748D00C69DBF /* batch_norm_6.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_6.w_2; sourceTree = ""; }; - C2C08DE62142748D00C69DBF /* batch_norm_14.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_14.w_0; sourceTree = ""; }; - C2C08DE72142748D00C69DBF /* batch_norm_28.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_28.w_0; sourceTree = ""; }; - C2C08DE82142748D00C69DBF /* conv2d_24.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_24.b_0; sourceTree = ""; }; - C2C08DE92142748D00C69DBF /* conv2d_7.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_7.w_0; sourceTree = ""; }; - C2C08DEA2142748D00C69DBF /* conv2d_30.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_30.b_0; sourceTree = ""; }; - C2C08DEB2142748D00C69DBF /* conv2d_31.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_31.b_0; sourceTree = ""; }; - C2C08DEC2142748D00C69DBF /* batch_norm_29.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_29.w_0; sourceTree = ""; }; - C2C08DED2142748D00C69DBF /* conv2d_6.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_6.w_0; sourceTree = ""; }; - C2C08DEE2142748D00C69DBF /* conv2d_25.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_25.b_0; sourceTree = ""; }; - C2C08DEF2142748D00C69DBF /* batch_norm_15.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_15.w_0; sourceTree = ""; }; - C2C08DF02142748D00C69DBF /* batch_norm_7.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_7.w_2; sourceTree = ""; }; - C2C08DF12142748D00C69DBF /* batch_norm_8.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_8.b_0; sourceTree = ""; }; - C2C08DF22142748D00C69DBF /* batch_norm_16.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_16.w_1; sourceTree = ""; }; - C2C08DF32142748D00C69DBF /* batch_norm_12.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_12.w_1; sourceTree = ""; }; - C2C08DF42142748D00C69DBF /* batch_norm_3.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_3.w_2; sourceTree = ""; }; - C2C08DF52142748D00C69DBF /* conv2d_2.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_2.w_0; sourceTree = ""; }; - C2C08DF62142748D00C69DBF /* batch_norm_11.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_11.w_0; sourceTree = ""; }; - C2C08DF72142748D00C69DBF /* batch_norm_10.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_10.w_0; sourceTree = ""; }; - C2C08DF82142748D00C69DBF /* conv2d_3.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_3.w_0; sourceTree = ""; }; - C2C08DF92142748D00C69DBF /* batch_norm_2.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_2.w_2; sourceTree = ""; }; - C2C08DFA2142748D00C69DBF /* depthwise_conv2d_12.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_12.w_0; sourceTree = ""; }; - C2C08DFB2142748D00C69DBF /* batch_norm_13.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_13.w_1; sourceTree = ""; }; - C2C08DFC2142748D00C69DBF /* batch_norm_11.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_11.w_1; sourceTree = ""; }; - C2C08DFD2142748D00C69DBF /* depthwise_conv2d_10.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_10.w_0; sourceTree = ""; }; - C2C08DFE2142748D00C69DBF /* batch_norm_0.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_0.w_2; sourceTree = ""; }; - C2C08DFF2142748D00C69DBF /* conv2d_22.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_22.b_0; sourceTree = ""; }; - C2C08E002142748D00C69DBF /* conv2d_1.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_1.w_0; sourceTree = ""; }; - C2C08E012142748D00C69DBF /* batch_norm_12.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_12.w_0; sourceTree = ""; }; - C2C08E022142748D00C69DBF /* batch_norm_13.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_13.w_0; sourceTree = ""; }; - C2C08E032142748D00C69DBF /* conv2d_0.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_0.w_0; sourceTree = ""; }; - C2C08E042142748D00C69DBF /* conv2d_23.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_23.b_0; sourceTree = ""; }; - C2C08E052142748D00C69DBF /* batch_norm_1.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_1.w_2; sourceTree = ""; }; - C2C08E062142748D00C69DBF /* batch_norm_10.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_10.w_1; sourceTree = ""; }; - C2C08E072142748D00C69DBF /* depthwise_conv2d_11.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_11.w_0; sourceTree = ""; }; - C2C08E082142748D00C69DBF /* depthwise_conv2d_3.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_3.w_0; sourceTree = ""; }; - C2C08E092142748D00C69DBF /* batch_norm_13.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_13.b_0; sourceTree = ""; }; - C2C08E0A2142748D00C69DBF /* conv2d_23.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_23.w_0; sourceTree = ""; }; - C2C08E0B2142748D00C69DBF /* batch_norm_20.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_20.w_2; sourceTree = ""; }; - C2C08E0C2142748D00C69DBF /* batch_norm_34.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_34.w_2; sourceTree = ""; }; - C2C08E0D2142748D00C69DBF /* batch_norm_21.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_21.w_2; sourceTree = ""; }; - C2C08E0E2142748D00C69DBF /* conv2d_22.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_22.w_0; sourceTree = ""; }; - C2C08E0F2142748D00C69DBF /* batch_norm_12.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_12.b_0; sourceTree = ""; }; - C2C08E102142748D00C69DBF /* depthwise_conv2d_2.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_2.w_0; sourceTree = ""; }; - C2C08E112142748D00C69DBF /* depthwise_conv2d_0.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_0.w_0; sourceTree = ""; }; - C2C08E122142748D00C69DBF /* batch_norm_10.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_10.b_0; sourceTree = ""; }; - C2C08E132142748D00C69DBF /* conv2d_20.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_20.w_0; sourceTree = ""; }; - C2C08E142142748D00C69DBF /* batch_norm_23.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_23.w_2; sourceTree = ""; }; - C2C08E152142748D00C69DBF /* batch_norm_22.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_22.w_2; sourceTree = ""; }; - C2C08E162142748D00C69DBF /* conv2d_21.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_21.w_0; sourceTree = ""; }; - C2C08E172142748D00C69DBF /* batch_norm_11.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_11.b_0; sourceTree = ""; }; - C2C08E182142748D00C69DBF /* depthwise_conv2d_1.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_1.w_0; sourceTree = ""; }; - C2C08E192142748D00C69DBF /* depthwise_conv2d_5.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_5.w_0; sourceTree = ""; }; - C2C08E1A2142748D00C69DBF /* batch_norm_8.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_8.w_0; sourceTree = ""; }; - C2C08E1B2142748D00C69DBF /* conv2d_25.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_25.w_0; sourceTree = ""; }; - C2C08E1C2142748D00C69DBF /* batch_norm_29.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_29.b_0; sourceTree = ""; }; - C2C08E1D2142748D00C69DBF /* conv2d_31.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_31.w_0; sourceTree = ""; }; - C2C08E1E2142748D00C69DBF /* conv2d_19.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_19.w_0; sourceTree = ""; }; - C2C08E1F2142748D00C69DBF /* batch_norm_15.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_15.b_0; sourceTree = ""; }; - C2C08E202142748D00C69DBF /* batch_norm_32.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_32.w_2; sourceTree = ""; }; - C2C08E212142748D00C69DBF /* batch_norm_26.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_26.w_2; sourceTree = ""; }; - C2C08E222142748D00C69DBF /* batch_norm_27.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_27.w_2; sourceTree = ""; }; - C2C08E232142748D00C69DBF /* batch_norm_33.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_33.w_2; sourceTree = ""; }; - C2C08E242142748D00C69DBF /* conv2d_18.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_18.w_0; sourceTree = ""; }; - C2C08E252142748D00C69DBF /* batch_norm_14.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_14.b_0; sourceTree = ""; }; - C2C08E262142748D00C69DBF /* conv2d_30.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_30.w_0; sourceTree = ""; }; - C2C08E272142748D00C69DBF /* conv2d_24.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_24.w_0; sourceTree = ""; }; - C2C08E282142748D00C69DBF /* batch_norm_28.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_28.b_0; sourceTree = ""; }; - C2C08E292142748D00C69DBF /* batch_norm_9.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_9.w_0; sourceTree = ""; }; - C2C08E2A2142748D00C69DBF /* depthwise_conv2d_4.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_4.w_0; sourceTree = ""; }; - C2C08E2B2142748D00C69DBF /* depthwise_conv2d_6.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_6.w_0; sourceTree = ""; }; - C2C08E2C2142748D00C69DBF /* conv2d_32.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_32.w_0; sourceTree = ""; }; - C2C08E2D2142748D00C69DBF /* conv2d_26.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_26.w_0; sourceTree = ""; }; - C2C08E2E2142748D00C69DBF /* batch_norm_16.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_16.b_0; sourceTree = ""; }; - C2C08E2F2142748D00C69DBF /* batch_norm_19.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_19.w_2; sourceTree = ""; }; - C2C08E302142748D00C69DBF /* batch_norm_25.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_25.w_2; sourceTree = ""; }; - C2C08E312142748D00C69DBF /* batch_norm_31.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_31.w_2; sourceTree = ""; }; - C2C08E322142748D00C69DBF /* batch_norm_8.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_8.w_1; sourceTree = ""; }; - C2C08E332142748D00C69DBF /* batch_norm_9.w_1 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_9.w_1; sourceTree = ""; }; - C2C08E342142748D00C69DBF /* batch_norm_30.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_30.w_2; sourceTree = ""; }; - C2C08E352142748D00C69DBF /* batch_norm_24.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_24.w_2; sourceTree = ""; }; - C2C08E362142748D00C69DBF /* batch_norm_18.w_2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_18.w_2; sourceTree = ""; }; - C2C08E372142748D00C69DBF /* batch_norm_17.b_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = batch_norm_17.b_0; sourceTree = ""; }; - C2C08E382142748D00C69DBF /* conv2d_27.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_27.w_0; sourceTree = ""; }; - C2C08E392142748D00C69DBF /* conv2d_33.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = conv2d_33.w_0; sourceTree = ""; }; - C2C08E3A2142748D00C69DBF /* depthwise_conv2d_7.w_0 */ = {isa = PBXFileReference; lastKnownFileType = file; path = depthwise_conv2d_7.w_0; sourceTree = ""; }; FC013927210204A3008100E3 /* PreProcessKernel.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = PreProcessKernel.metal; sourceTree = ""; }; FC039B7E20E11C550081E9F8 /* paddle-mobile-demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "paddle-mobile-demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; FC039B8120E11C550081E9F8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -485,8 +63,24 @@ FC039B8D20E11C560081E9F8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; FC27991121343A39000B6BAD /* paddle-mobile-demo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "paddle-mobile-demo-Bridging-Header.h"; sourceTree = ""; }; FC4FD97B2140EE250073E130 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; + FC803BCB214D27920094B8E5 /* FPSCounter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FPSCounter.swift; sourceTree = ""; }; + FC803BCC214D27920094B8E5 /* VideoCapture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoCapture.swift; sourceTree = ""; }; + FC8CFEE42135452B0094D569 /* genet_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = genet_params; sourceTree = ""; }; + FC8CFEE52135452B0094D569 /* genet_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = genet_model; sourceTree = ""; }; + FC8CFEF6213551D00094D569 /* params */ = {isa = PBXFileReference; lastKnownFileType = file; path = params; sourceTree = ""; }; + FC8CFEF7213551D00094D569 /* model */ = {isa = PBXFileReference; lastKnownFileType = file; path = model; sourceTree = ""; }; + FC918190211DBC3500B6F354 /* paddle-mobile.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "paddle-mobile.png"; sourceTree = ""; }; + FC918192211DC70500B6F354 /* iphone.JPG */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = iphone.JPG; sourceTree = ""; }; + FC9A19E52148C38400CD9CBF /* ar_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = ar_model; sourceTree = ""; }; + FC9A19E62148C38400CD9CBF /* ar_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = ar_params; sourceTree = ""; }; + FCA3A16021313E1F00084FE5 /* hand.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = hand.jpg; sourceTree = ""; }; + FCBCCC502122EEDC00D94F7E /* ssd_hand_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = ssd_hand_params; sourceTree = ""; }; + FCBCCC512122EEDC00D94F7E /* ssd_hand_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = ssd_hand_model; sourceTree = ""; }; FCBCCC542122EF5400D94F7E /* MetalHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MetalHelper.swift; sourceTree = ""; }; + FCDFD41A211D91C7005AB38B /* synset.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = synset.txt; sourceTree = ""; }; FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = paddle_mobile.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + FCEEE7D3210627A000444BEC /* banana.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = banana.jpeg; sourceTree = ""; }; + FCF437E7214B6DDB00943429 /* MultiPredictViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiPredictViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -520,338 +114,121 @@ name = Frameworks; sourceTree = ""; }; - C23717852148E5A50092444E /* fluid_fssd_new_ar */ = { - isa = PBXGroup; - children = ( - C23717862148E5A50092444E /* ar_model */, - C23717872148E5A50092444E /* ar_params */, - ); - path = fluid_fssd_new_ar; - sourceTree = ""; - }; - C2C08D5A2142748D00C69DBF /* images */ = { + FC039B7520E11C550081E9F8 = { isa = PBXGroup; children = ( - C2C08D5B2142748D00C69DBF /* synset.txt */, - C2C08D5C2142748D00C69DBF /* banana.jpeg */, - C2C08D5D2142748D00C69DBF /* hand.jpg */, - C2C08D5E2142748D00C69DBF /* iphone.JPG */, - C2C08D5F2142748D00C69DBF /* paddle-mobile.png */, + FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */, + FC039B8020E11C550081E9F8 /* paddle-mobile-demo */, + FC039B7F20E11C550081E9F8 /* Products */, + 5722B50FEC38F55CA9B6A57B /* Pods */, + 7B7DED984E9EE7BFB45E24E8 /* Frameworks */, ); - path = images; sourceTree = ""; }; - C2C08D602142748D00C69DBF /* models */ = { + FC039B7F20E11C550081E9F8 /* Products */ = { isa = PBXGroup; children = ( - C23717852148E5A50092444E /* fluid_fssd_new_ar */, - C2C08D612142748D00C69DBF /* mobilenet */, - C2C08D642142748D00C69DBF /* genet */, - C2C08D672142748D00C69DBF /* mobilenet_ssd_hand */, - C2C08D6A2142748D00C69DBF /* yolo */, - C2C08D6F2142748D00C69DBF /* mobilenet_combine */, - C2C08D722142748D00C69DBF /* mobilenetssd */, + FC039B7E20E11C550081E9F8 /* paddle-mobile-demo.app */, ); - path = models; + name = Products; sourceTree = ""; }; - C2C08D612142748D00C69DBF /* mobilenet */ = { + FC039B8020E11C550081E9F8 /* paddle-mobile-demo */ = { isa = PBXGroup; children = ( - C2C08D622142748D00C69DBF /* params */, - C2C08D632142748D00C69DBF /* model */, + FC803BCA214D27920094B8E5 /* VideoCapture */, + FC8CFED2213519540094D569 /* Net */, + FC0E2C2020EDC03B009C1FAC /* models */, + FC0E2C1D20EDC030009C1FAC /* images */, + FC039B8120E11C550081E9F8 /* AppDelegate.swift */, + FC039B8320E11C550081E9F8 /* ViewController.swift */, + FC039B8520E11C550081E9F8 /* Main.storyboard */, + FC039B8820E11C560081E9F8 /* Assets.xcassets */, + FC039B8A20E11C560081E9F8 /* LaunchScreen.storyboard */, + FC039B8D20E11C560081E9F8 /* Info.plist */, + FC27991121343A39000B6BAD /* paddle-mobile-demo-Bridging-Header.h */, + FCF437E7214B6DDB00943429 /* MultiPredictViewController.swift */, ); - path = mobilenet; + path = "paddle-mobile-demo"; sourceTree = ""; }; - C2C08D642142748D00C69DBF /* genet */ = { + FC0E2C1D20EDC030009C1FAC /* images */ = { isa = PBXGroup; children = ( - C2C08D652142748D00C69DBF /* genet_params */, - C2C08D662142748D00C69DBF /* genet_model */, - ); - path = genet; + FCA3A16021313E1F00084FE5 /* hand.jpg */, + FC918192211DC70500B6F354 /* iphone.JPG */, + FC918190211DBC3500B6F354 /* paddle-mobile.png */, + FCDFD41A211D91C7005AB38B /* synset.txt */, + FCEEE7D3210627A000444BEC /* banana.jpeg */, + ); + name = images; + path = ../../images; sourceTree = ""; }; - C2C08D672142748D00C69DBF /* mobilenet_ssd_hand */ = { + FC0E2C2020EDC03B009C1FAC /* models */ = { isa = PBXGroup; children = ( - C2C08D682142748D00C69DBF /* ssd_hand_params */, - C2C08D692142748D00C69DBF /* ssd_hand_model */, + FC9A19E42148C38400CD9CBF /* fluid_fssd_new_ar */, + FC8CFEF5213551D00094D569 /* mobilenet */, + FC8CFEE32135452B0094D569 /* genet */, + FCBCCC4F2122EEDC00D94F7E /* mobilenet_ssd_hand */, ); - path = mobilenet_ssd_hand; + name = models; + path = ../../models; sourceTree = ""; }; - C2C08D6A2142748D00C69DBF /* yolo */ = { + FC803BCA214D27920094B8E5 /* VideoCapture */ = { isa = PBXGroup; children = ( - C2C08D6B2142748D00C69DBF /* mobilenet */, - C2C08D6C2142748D00C69DBF /* params */, - C2C08D6D2142748D00C69DBF /* model */, - C2C08D6E2142748D00C69DBF /* yolo */, + FC803BCB214D27920094B8E5 /* FPSCounter.swift */, + FC803BCC214D27920094B8E5 /* VideoCapture.swift */, ); - path = yolo; + path = VideoCapture; sourceTree = ""; }; - C2C08D6F2142748D00C69DBF /* mobilenet_combine */ = { - isa = PBXGroup; - children = ( - C2C08D702142748D00C69DBF /* params */, - C2C08D712142748D00C69DBF /* model */, - ); - path = mobilenet_combine; - sourceTree = ""; - }; - C2C08D722142748D00C69DBF /* mobilenetssd */ = { + FC8CFED2213519540094D569 /* Net */ = { isa = PBXGroup; children = ( - C2C08D732142748D00C69DBF /* batch_norm_7.w_0 */, - C2C08D742142748D00C69DBF /* batch_norm_26.b_0 */, - C2C08D752142748D00C69DBF /* batch_norm_32.b_0 */, - C2C08D762142748D00C69DBF /* conv2d_16.w_0 */, - C2C08D772142748D00C69DBF /* batch_norm_15.w_2 */, - C2C08D782142748D00C69DBF /* batch_norm_29.w_2 */, - C2C08D792142748D00C69DBF /* batch_norm_4.w_1 */, - C2C08D7A2142748D00C69DBF /* batch_norm_5.w_1 */, - C2C08D7B2142748D00C69DBF /* batch_norm_28.w_2 */, - C2C08D7C2142748D00C69DBF /* batch_norm_14.w_2 */, - C2C08D7D2142748D00C69DBF /* conv2d_17.w_0 */, - C2C08D7E2142748D00C69DBF /* batch_norm_33.b_0 */, - C2C08D7F2142748D00C69DBF /* batch_norm_27.b_0 */, - C2C08D802142748D00C69DBF /* batch_norm_6.w_0 */, - C2C08D812142748D00C69DBF /* batch_norm_4.w_0 */, - C2C08D822142748D00C69DBF /* depthwise_conv2d_9.w_0 */, - C2C08D832142748D00C69DBF /* batch_norm_31.b_0 */, - C2C08D842142748D00C69DBF /* conv2d_29.w_0 */, - C2C08D852142748D00C69DBF /* batch_norm_25.b_0 */, - C2C08D862142748D00C69DBF /* conv2d_15.w_0 */, - C2C08D872142748D00C69DBF /* batch_norm_19.b_0 */, - C2C08D882142748D00C69DBF /* batch_norm_16.w_2 */, - C2C08D892142748D00C69DBF /* __model__ */, - C2C08D8A2142748D00C69DBF /* batch_norm_7.w_1 */, - C2C08D8B2142748D00C69DBF /* batch_norm_6.w_1 */, - C2C08D8C2142748D00C69DBF /* batch_norm_17.w_2 */, - C2C08D8D2142748D00C69DBF /* conv2d_14.w_0 */, - C2C08D8E2142748D00C69DBF /* batch_norm_18.b_0 */, - C2C08D8F2142748D00C69DBF /* conv2d_28.w_0 */, - C2C08D902142748D00C69DBF /* batch_norm_24.b_0 */, - C2C08D912142748D00C69DBF /* batch_norm_30.b_0 */, - C2C08D922142748D00C69DBF /* depthwise_conv2d_8.w_0 */, - C2C08D932142748D00C69DBF /* batch_norm_5.w_0 */, - C2C08D942142748D00C69DBF /* batch_norm_1.w_0 */, - C2C08D952142748D00C69DBF /* conv2d_10.w_0 */, - C2C08D962142748D00C69DBF /* batch_norm_34.b_0 */, - C2C08D972142748D00C69DBF /* batch_norm_20.b_0 */, - C2C08D982142748D00C69DBF /* batch_norm_13.w_2 */, - C2C08D992142748D00C69DBF /* batch_norm_2.w_1 */, - C2C08D9A2142748D00C69DBF /* batch_norm_3.w_1 */, - C2C08D9B2142748D00C69DBF /* batch_norm_12.w_2 */, - C2C08D9C2142748D00C69DBF /* batch_norm_21.b_0 */, - C2C08D9D2142748D00C69DBF /* conv2d_11.w_0 */, - C2C08D9E2142748D00C69DBF /* batch_norm_0.w_0 */, - C2C08D9F2142748D00C69DBF /* batch_norm_2.w_0 */, - C2C08DA02142748D00C69DBF /* conv2d_13.w_0 */, - C2C08DA12142748D00C69DBF /* batch_norm_23.b_0 */, - C2C08DA22142748D00C69DBF /* batch_norm_10.w_2 */, - C2C08DA32142748D00C69DBF /* batch_norm_1.w_1 */, - C2C08DA42142748D00C69DBF /* batch_norm_0.w_1 */, - C2C08DA52142748D00C69DBF /* batch_norm_11.w_2 */, - C2C08DA62142748D00C69DBF /* batch_norm_22.b_0 */, - C2C08DA72142748D00C69DBF /* conv2d_12.w_0 */, - C2C08DA82142748D00C69DBF /* batch_norm_3.w_0 */, - C2C08DA92142748D00C69DBF /* batch_norm_21.w_1 */, - C2C08DAA2142748D00C69DBF /* batch_norm_3.b_0 */, - C2C08DAB2142748D00C69DBF /* batch_norm_22.w_0 */, - C2C08DAC2142748D00C69DBF /* batch_norm_23.w_0 */, - C2C08DAD2142748D00C69DBF /* batch_norm_2.b_0 */, - C2C08DAE2142748D00C69DBF /* batch_norm_20.w_1 */, - C2C08DAF2142748D00C69DBF /* batch_norm_34.w_1 */, - C2C08DB02142748D00C69DBF /* batch_norm_22.w_1 */, - C2C08DB12142748D00C69DBF /* batch_norm_0.b_0 */, - C2C08DB22142748D00C69DBF /* batch_norm_21.w_0 */, - C2C08DB32142748D00C69DBF /* batch_norm_20.w_0 */, - C2C08DB42142748D00C69DBF /* batch_norm_34.w_0 */, - C2C08DB52142748D00C69DBF /* batch_norm_1.b_0 */, - C2C08DB62142748D00C69DBF /* batch_norm_23.w_1 */, - C2C08DB72142748D00C69DBF /* batch_norm_27.w_1 */, - C2C08DB82142748D00C69DBF /* batch_norm_33.w_1 */, - C2C08DB92142748D00C69DBF /* batch_norm_5.b_0 */, - C2C08DBA2142748D00C69DBF /* batch_norm_18.w_0 */, - C2C08DBB2142748D00C69DBF /* batch_norm_30.w_0 */, - C2C08DBC2142748D00C69DBF /* batch_norm_24.w_0 */, - C2C08DBD2142748D00C69DBF /* conv2d_28.b_0 */, - C2C08DBE2142748D00C69DBF /* batch_norm_25.w_0 */, - C2C08DBF2142748D00C69DBF /* conv2d_29.b_0 */, - C2C08DC02142748D00C69DBF /* batch_norm_31.w_0 */, - C2C08DC12142748D00C69DBF /* batch_norm_19.w_0 */, - C2C08DC22142748D00C69DBF /* batch_norm_4.b_0 */, - C2C08DC32142748D00C69DBF /* batch_norm_32.w_1 */, - C2C08DC42142748D00C69DBF /* batch_norm_26.w_1 */, - C2C08DC52142748D00C69DBF /* batch_norm_30.w_1 */, - C2C08DC62142748D00C69DBF /* batch_norm_24.w_1 */, - C2C08DC72142748D00C69DBF /* batch_norm_18.w_1 */, - C2C08DC82142748D00C69DBF /* batch_norm_6.b_0 */, - C2C08DC92142748D00C69DBF /* batch_norm_9.w_2 */, - C2C08DCA2142748D00C69DBF /* conv2d_8.w_0 */, - C2C08DCB2142748D00C69DBF /* batch_norm_27.w_0 */, - C2C08DCC2142748D00C69DBF /* batch_norm_33.w_0 */, - C2C08DCD2142748D00C69DBF /* batch_norm_32.w_0 */, - C2C08DCE2142748D00C69DBF /* conv2d_9.w_0 */, - C2C08DCF2142748D00C69DBF /* batch_norm_26.w_0 */, - C2C08DD02142748D00C69DBF /* batch_norm_8.w_2 */, - C2C08DD12142748D00C69DBF /* batch_norm_7.b_0 */, - C2C08DD22142748D00C69DBF /* batch_norm_19.w_1 */, - C2C08DD32142748D00C69DBF /* batch_norm_25.w_1 */, - C2C08DD42142748D00C69DBF /* batch_norm_31.w_1 */, - C2C08DD52142748D00C69DBF /* batch_norm_28.w_1 */, - C2C08DD62142748D00C69DBF /* batch_norm_14.w_1 */, - C2C08DD72142748D00C69DBF /* batch_norm_5.w_2 */, - C2C08DD82142748D00C69DBF /* batch_norm_17.w_0 */, - C2C08DD92142748D00C69DBF /* conv2d_33.b_0 */, - C2C08DDA2142748D00C69DBF /* conv2d_27.b_0 */, - C2C08DDB2142748D00C69DBF /* conv2d_4.w_0 */, - C2C08DDC2142748D00C69DBF /* conv2d_5.w_0 */, - C2C08DDD2142748D00C69DBF /* conv2d_26.b_0 */, - C2C08DDE2142748D00C69DBF /* conv2d_32.b_0 */, - C2C08DDF2142748D00C69DBF /* batch_norm_16.w_0 */, - C2C08DE02142748D00C69DBF /* batch_norm_4.w_2 */, - C2C08DE12142748D00C69DBF /* batch_norm_15.w_1 */, - C2C08DE22142748D00C69DBF /* batch_norm_29.w_1 */, - C2C08DE32142748D00C69DBF /* batch_norm_17.w_1 */, - C2C08DE42142748D00C69DBF /* batch_norm_9.b_0 */, - C2C08DE52142748D00C69DBF /* batch_norm_6.w_2 */, - C2C08DE62142748D00C69DBF /* batch_norm_14.w_0 */, - C2C08DE72142748D00C69DBF /* batch_norm_28.w_0 */, - C2C08DE82142748D00C69DBF /* conv2d_24.b_0 */, - C2C08DE92142748D00C69DBF /* conv2d_7.w_0 */, - C2C08DEA2142748D00C69DBF /* conv2d_30.b_0 */, - C2C08DEB2142748D00C69DBF /* conv2d_31.b_0 */, - C2C08DEC2142748D00C69DBF /* batch_norm_29.w_0 */, - C2C08DED2142748D00C69DBF /* conv2d_6.w_0 */, - C2C08DEE2142748D00C69DBF /* conv2d_25.b_0 */, - C2C08DEF2142748D00C69DBF /* batch_norm_15.w_0 */, - C2C08DF02142748D00C69DBF /* batch_norm_7.w_2 */, - C2C08DF12142748D00C69DBF /* batch_norm_8.b_0 */, - C2C08DF22142748D00C69DBF /* batch_norm_16.w_1 */, - C2C08DF32142748D00C69DBF /* batch_norm_12.w_1 */, - C2C08DF42142748D00C69DBF /* batch_norm_3.w_2 */, - C2C08DF52142748D00C69DBF /* conv2d_2.w_0 */, - C2C08DF62142748D00C69DBF /* batch_norm_11.w_0 */, - C2C08DF72142748D00C69DBF /* batch_norm_10.w_0 */, - C2C08DF82142748D00C69DBF /* conv2d_3.w_0 */, - C2C08DF92142748D00C69DBF /* batch_norm_2.w_2 */, - C2C08DFA2142748D00C69DBF /* depthwise_conv2d_12.w_0 */, - C2C08DFB2142748D00C69DBF /* batch_norm_13.w_1 */, - C2C08DFC2142748D00C69DBF /* batch_norm_11.w_1 */, - C2C08DFD2142748D00C69DBF /* depthwise_conv2d_10.w_0 */, - C2C08DFE2142748D00C69DBF /* batch_norm_0.w_2 */, - C2C08DFF2142748D00C69DBF /* conv2d_22.b_0 */, - C2C08E002142748D00C69DBF /* conv2d_1.w_0 */, - C2C08E012142748D00C69DBF /* batch_norm_12.w_0 */, - C2C08E022142748D00C69DBF /* batch_norm_13.w_0 */, - C2C08E032142748D00C69DBF /* conv2d_0.w_0 */, - C2C08E042142748D00C69DBF /* conv2d_23.b_0 */, - C2C08E052142748D00C69DBF /* batch_norm_1.w_2 */, - C2C08E062142748D00C69DBF /* batch_norm_10.w_1 */, - C2C08E072142748D00C69DBF /* depthwise_conv2d_11.w_0 */, - C2C08E082142748D00C69DBF /* depthwise_conv2d_3.w_0 */, - C2C08E092142748D00C69DBF /* batch_norm_13.b_0 */, - C2C08E0A2142748D00C69DBF /* conv2d_23.w_0 */, - C2C08E0B2142748D00C69DBF /* batch_norm_20.w_2 */, - C2C08E0C2142748D00C69DBF /* batch_norm_34.w_2 */, - C2C08E0D2142748D00C69DBF /* batch_norm_21.w_2 */, - C2C08E0E2142748D00C69DBF /* conv2d_22.w_0 */, - C2C08E0F2142748D00C69DBF /* batch_norm_12.b_0 */, - C2C08E102142748D00C69DBF /* depthwise_conv2d_2.w_0 */, - C2C08E112142748D00C69DBF /* depthwise_conv2d_0.w_0 */, - C2C08E122142748D00C69DBF /* batch_norm_10.b_0 */, - C2C08E132142748D00C69DBF /* conv2d_20.w_0 */, - C2C08E142142748D00C69DBF /* batch_norm_23.w_2 */, - C2C08E152142748D00C69DBF /* batch_norm_22.w_2 */, - C2C08E162142748D00C69DBF /* conv2d_21.w_0 */, - C2C08E172142748D00C69DBF /* batch_norm_11.b_0 */, - C2C08E182142748D00C69DBF /* depthwise_conv2d_1.w_0 */, - C2C08E192142748D00C69DBF /* depthwise_conv2d_5.w_0 */, - C2C08E1A2142748D00C69DBF /* batch_norm_8.w_0 */, - C2C08E1B2142748D00C69DBF /* conv2d_25.w_0 */, - C2C08E1C2142748D00C69DBF /* batch_norm_29.b_0 */, - C2C08E1D2142748D00C69DBF /* conv2d_31.w_0 */, - C2C08E1E2142748D00C69DBF /* conv2d_19.w_0 */, - C2C08E1F2142748D00C69DBF /* batch_norm_15.b_0 */, - C2C08E202142748D00C69DBF /* batch_norm_32.w_2 */, - C2C08E212142748D00C69DBF /* batch_norm_26.w_2 */, - C2C08E222142748D00C69DBF /* batch_norm_27.w_2 */, - C2C08E232142748D00C69DBF /* batch_norm_33.w_2 */, - C2C08E242142748D00C69DBF /* conv2d_18.w_0 */, - C2C08E252142748D00C69DBF /* batch_norm_14.b_0 */, - C2C08E262142748D00C69DBF /* conv2d_30.w_0 */, - C2C08E272142748D00C69DBF /* conv2d_24.w_0 */, - C2C08E282142748D00C69DBF /* batch_norm_28.b_0 */, - C2C08E292142748D00C69DBF /* batch_norm_9.w_0 */, - C2C08E2A2142748D00C69DBF /* depthwise_conv2d_4.w_0 */, - C2C08E2B2142748D00C69DBF /* depthwise_conv2d_6.w_0 */, - C2C08E2C2142748D00C69DBF /* conv2d_32.w_0 */, - C2C08E2D2142748D00C69DBF /* conv2d_26.w_0 */, - C2C08E2E2142748D00C69DBF /* batch_norm_16.b_0 */, - C2C08E2F2142748D00C69DBF /* batch_norm_19.w_2 */, - C2C08E302142748D00C69DBF /* batch_norm_25.w_2 */, - C2C08E312142748D00C69DBF /* batch_norm_31.w_2 */, - C2C08E322142748D00C69DBF /* batch_norm_8.w_1 */, - C2C08E332142748D00C69DBF /* batch_norm_9.w_1 */, - C2C08E342142748D00C69DBF /* batch_norm_30.w_2 */, - C2C08E352142748D00C69DBF /* batch_norm_24.w_2 */, - C2C08E362142748D00C69DBF /* batch_norm_18.w_2 */, - C2C08E372142748D00C69DBF /* batch_norm_17.b_0 */, - C2C08E382142748D00C69DBF /* conv2d_27.w_0 */, - C2C08E392142748D00C69DBF /* conv2d_33.w_0 */, - C2C08E3A2142748D00C69DBF /* depthwise_conv2d_7.w_0 */, + FC013927210204A3008100E3 /* PreProcessKernel.metal */, + FCBCCC542122EF5400D94F7E /* MetalHelper.swift */, ); - path = mobilenetssd; + path = Net; sourceTree = ""; }; - FC039B7520E11C550081E9F8 = { + FC8CFEE32135452B0094D569 /* genet */ = { isa = PBXGroup; children = ( - FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */, - FC039B8020E11C550081E9F8 /* paddle-mobile-demo */, - FC039B7F20E11C550081E9F8 /* Products */, - 5722B50FEC38F55CA9B6A57B /* Pods */, - 7B7DED984E9EE7BFB45E24E8 /* Frameworks */, + FC8CFEE42135452B0094D569 /* genet_params */, + FC8CFEE52135452B0094D569 /* genet_model */, ); + path = genet; sourceTree = ""; }; - FC039B7F20E11C550081E9F8 /* Products */ = { + FC8CFEF5213551D00094D569 /* mobilenet */ = { isa = PBXGroup; children = ( - FC039B7E20E11C550081E9F8 /* paddle-mobile-demo.app */, + FC8CFEF6213551D00094D569 /* params */, + FC8CFEF7213551D00094D569 /* model */, ); - name = Products; + path = mobilenet; sourceTree = ""; }; - FC039B8020E11C550081E9F8 /* paddle-mobile-demo */ = { + FC9A19E42148C38400CD9CBF /* fluid_fssd_new_ar */ = { isa = PBXGroup; children = ( - C2C08D5A2142748D00C69DBF /* images */, - C2C08D602142748D00C69DBF /* models */, - FC8CFED2213519540094D569 /* Net */, - FC039B8120E11C550081E9F8 /* AppDelegate.swift */, - FC039B8320E11C550081E9F8 /* ViewController.swift */, - FC039B8520E11C550081E9F8 /* Main.storyboard */, - FC039B8820E11C560081E9F8 /* Assets.xcassets */, - FC039B8A20E11C560081E9F8 /* LaunchScreen.storyboard */, - FC039B8D20E11C560081E9F8 /* Info.plist */, - FC27991121343A39000B6BAD /* paddle-mobile-demo-Bridging-Header.h */, + FC9A19E52148C38400CD9CBF /* ar_model */, + FC9A19E62148C38400CD9CBF /* ar_params */, ); - path = "paddle-mobile-demo"; + path = fluid_fssd_new_ar; sourceTree = ""; }; - FC8CFED2213519540094D569 /* Net */ = { + FCBCCC4F2122EEDC00D94F7E /* mobilenet_ssd_hand */ = { isa = PBXGroup; children = ( - FC013927210204A3008100E3 /* PreProcessKernel.metal */, - FCBCCC542122EF5400D94F7E /* MetalHelper.swift */, + FCBCCC502122EEDC00D94F7E /* ssd_hand_params */, + FCBCCC512122EEDC00D94F7E /* ssd_hand_model */, ); - path = Net; + path = mobilenet_ssd_hand; sourceTree = ""; }; /* End PBXGroup section */ @@ -916,228 +293,22 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + FC8CFEF8213551D10094D569 /* params in Resources */, FC039B8C20E11C560081E9F8 /* LaunchScreen.storyboard in Resources */, - C2C08E722142748D00C69DBF /* batch_norm_2.w_1 in Resources */, - C2C08EB22142748D00C69DBF /* conv2d_33.b_0 in Resources */, - C2C08E522142748D00C69DBF /* batch_norm_4.w_1 in Resources */, - C2C08ED92142748D00C69DBF /* conv2d_1.w_0 in Resources */, - C2C08E612142748D00C69DBF /* batch_norm_16.w_2 in Resources */, - C2C08E7C2142748D00C69DBF /* batch_norm_1.w_1 in Resources */, - C2C08EE62142748D00C69DBF /* batch_norm_21.w_2 in Resources */, - C2C08E3C2142748D00C69DBF /* banana.jpeg in Resources */, - C2C08EA92142748D00C69DBF /* batch_norm_8.w_2 in Resources */, - C2C08EA82142748D00C69DBF /* batch_norm_26.w_0 in Resources */, - C2C08EDC2142748D00C69DBF /* conv2d_0.w_0 in Resources */, - C2C08EBE2142748D00C69DBF /* batch_norm_6.w_2 in Resources */, - C2C08E4A2142748D00C69DBF /* params in Resources */, - C2C08EE32142748D00C69DBF /* conv2d_23.w_0 in Resources */, - C2C08EE52142748D00C69DBF /* batch_norm_34.w_2 in Resources */, - C2C08E672142748D00C69DBF /* batch_norm_18.b_0 in Resources */, - C2C08E972142748D00C69DBF /* batch_norm_25.w_0 in Resources */, - C2C08E432142748D00C69DBF /* genet_model in Resources */, - C2C08EFC2142748D00C69DBF /* batch_norm_33.w_2 in Resources */, - C2C08EC72142748D00C69DBF /* conv2d_25.b_0 in Resources */, - C2C08EB62142748D00C69DBF /* conv2d_26.b_0 in Resources */, - C2C08F0C2142748D00C69DBF /* batch_norm_9.w_1 in Resources */, - C2C08E5E2142748D00C69DBF /* batch_norm_25.b_0 in Resources */, - C2C08E832142748D00C69DBF /* batch_norm_3.b_0 in Resources */, - C2C08ED42142748D00C69DBF /* batch_norm_13.w_1 in Resources */, - C2C08EC42142748D00C69DBF /* conv2d_31.b_0 in Resources */, - C2C08E582142748D00C69DBF /* batch_norm_27.b_0 in Resources */, - C2C08E442142748D00C69DBF /* ssd_hand_params in Resources */, - C2C08E562142748D00C69DBF /* conv2d_17.w_0 in Resources */, - C2C08E8E2142748D00C69DBF /* batch_norm_1.b_0 in Resources */, - C2C08ED52142748D00C69DBF /* batch_norm_11.w_1 in Resources */, - C2C08F042142748D00C69DBF /* depthwise_conv2d_6.w_0 in Resources */, - C2C08E8A2142748D00C69DBF /* batch_norm_0.b_0 in Resources */, - C2C08E9E2142748D00C69DBF /* batch_norm_30.w_1 in Resources */, - C2C08EFB2142748D00C69DBF /* batch_norm_27.w_2 in Resources */, - C2C08E882142748D00C69DBF /* batch_norm_34.w_1 in Resources */, - C2C08E6C2142748D00C69DBF /* batch_norm_5.w_0 in Resources */, - C2C08E532142748D00C69DBF /* batch_norm_5.w_1 in Resources */, - C2C08EAF2142748D00C69DBF /* batch_norm_14.w_1 in Resources */, - C2C08F082142748D00C69DBF /* batch_norm_19.w_2 in Resources */, - C2C08E9D2142748D00C69DBF /* batch_norm_26.w_1 in Resources */, - C2C08EEC2142748D00C69DBF /* conv2d_20.w_0 in Resources */, - C2C08E8C2142748D00C69DBF /* batch_norm_20.w_0 in Resources */, - C2C08EEF2142748D00C69DBF /* conv2d_21.w_0 in Resources */, - C2C08EDF2142748D00C69DBF /* batch_norm_10.w_1 in Resources */, - C2C08EBD2142748D00C69DBF /* batch_norm_9.b_0 in Resources */, - C2C08E652142748D00C69DBF /* batch_norm_17.w_2 in Resources */, - C2C08E902142748D00C69DBF /* batch_norm_27.w_1 in Resources */, - C2C08F112142748D00C69DBF /* conv2d_27.w_0 in Resources */, - C2C08EAA2142748D00C69DBF /* batch_norm_7.b_0 in Resources */, - C2C08E4C2142748D00C69DBF /* batch_norm_7.w_0 in Resources */, - C2C08E402142748D00C69DBF /* params in Resources */, - C2C08E662142748D00C69DBF /* conv2d_14.w_0 in Resources */, - C2C08E4B2142748D00C69DBF /* model in Resources */, - C2C08EFE2142748D00C69DBF /* batch_norm_14.b_0 in Resources */, - C2C08ECD2142748D00C69DBF /* batch_norm_3.w_2 in Resources */, - C2C08E9B2142748D00C69DBF /* batch_norm_4.b_0 in Resources */, - C2C08E842142748D00C69DBF /* batch_norm_22.w_0 in Resources */, - C2C08EB32142748D00C69DBF /* conv2d_27.b_0 in Resources */, - C2C08EA32142748D00C69DBF /* conv2d_8.w_0 in Resources */, - C2C08EA62142748D00C69DBF /* batch_norm_32.w_0 in Resources */, - C2C08E6B2142748D00C69DBF /* depthwise_conv2d_8.w_0 in Resources */, - C2C08E6F2142748D00C69DBF /* batch_norm_34.b_0 in Resources */, - C2C08ED02142748D00C69DBF /* batch_norm_10.w_0 in Resources */, - C2C08EE82142748D00C69DBF /* batch_norm_12.b_0 in Resources */, - C2C08E602142748D00C69DBF /* batch_norm_19.b_0 in Resources */, - C2C08E992142748D00C69DBF /* batch_norm_31.w_0 in Resources */, - C2C08E932142748D00C69DBF /* batch_norm_18.w_0 in Resources */, - C2C08EE02142748D00C69DBF /* depthwise_conv2d_11.w_0 in Resources */, + FC8CFEF9213551D10094D569 /* model in Resources */, + FC918191211DBC3500B6F354 /* paddle-mobile.png in Resources */, + FC8CFEE72135452C0094D569 /* genet_model in Resources */, FC039B8920E11C560081E9F8 /* Assets.xcassets in Resources */, - C2C08E4E2142748D00C69DBF /* batch_norm_32.b_0 in Resources */, - C2C08EE92142748D00C69DBF /* depthwise_conv2d_2.w_0 in Resources */, - C2C08EC92142748D00C69DBF /* batch_norm_7.w_2 in Resources */, - C2C08E8F2142748D00C69DBF /* batch_norm_23.w_1 in Resources */, - C2C08E3F2142748D00C69DBF /* paddle-mobile.png in Resources */, - C2C08E9F2142748D00C69DBF /* batch_norm_24.w_1 in Resources */, - C2C08E4F2142748D00C69DBF /* conv2d_16.w_0 in Resources */, - C2C08E792142748D00C69DBF /* conv2d_13.w_0 in Resources */, - C2C08EBA2142748D00C69DBF /* batch_norm_15.w_1 in Resources */, - C2C08ECF2142748D00C69DBF /* batch_norm_11.w_0 in Resources */, - C2C08EF02142748D00C69DBF /* batch_norm_11.b_0 in Resources */, - C2C08E8B2142748D00C69DBF /* batch_norm_21.w_0 in Resources */, - C2C08E742142748D00C69DBF /* batch_norm_12.w_2 in Resources */, - C2C08E492142748D00C69DBF /* yolo in Resources */, - C2C08E3E2142748D00C69DBF /* iphone.JPG in Resources */, - C2C08E762142748D00C69DBF /* conv2d_11.w_0 in Resources */, - C2C08F102142748D00C69DBF /* batch_norm_17.b_0 in Resources */, - C2C08E7F2142748D00C69DBF /* batch_norm_22.b_0 in Resources */, - C2C08EB12142748D00C69DBF /* batch_norm_17.w_0 in Resources */, - C2C08EF12142748D00C69DBF /* depthwise_conv2d_1.w_0 in Resources */, - C2C08EB52142748D00C69DBF /* conv2d_5.w_0 in Resources */, - C2C08EF32142748D00C69DBF /* batch_norm_8.w_0 in Resources */, - C2C08EB72142748D00C69DBF /* conv2d_32.b_0 in Resources */, - C2C08EF72142748D00C69DBF /* conv2d_19.w_0 in Resources */, - C2C08E782142748D00C69DBF /* batch_norm_2.w_0 in Resources */, - C2C08EF92142748D00C69DBF /* batch_norm_32.w_2 in Resources */, - C2C08E872142748D00C69DBF /* batch_norm_20.w_1 in Resources */, - C2C08E462142748D00C69DBF /* mobilenet in Resources */, - C2C08EBB2142748D00C69DBF /* batch_norm_29.w_1 in Resources */, - C2C08EE42142748D00C69DBF /* batch_norm_20.w_2 in Resources */, - C2C08EFD2142748D00C69DBF /* conv2d_18.w_0 in Resources */, - C2C08E5C2142748D00C69DBF /* batch_norm_31.b_0 in Resources */, - C2C08EF82142748D00C69DBF /* batch_norm_15.b_0 in Resources */, - C2C08E982142748D00C69DBF /* conv2d_29.b_0 in Resources */, - C2C08EEE2142748D00C69DBF /* batch_norm_22.w_2 in Resources */, - C2C08E852142748D00C69DBF /* batch_norm_23.w_0 in Resources */, - C2C08EA12142748D00C69DBF /* batch_norm_6.b_0 in Resources */, - C2C08EA52142748D00C69DBF /* batch_norm_33.w_0 in Resources */, - C2C08E6A2142748D00C69DBF /* batch_norm_30.b_0 in Resources */, - C2C08E572142748D00C69DBF /* batch_norm_33.b_0 in Resources */, - C2C08E7B2142748D00C69DBF /* batch_norm_10.w_2 in Resources */, - C2C08EAE2142748D00C69DBF /* batch_norm_28.w_1 in Resources */, - C2C08EA22142748D00C69DBF /* batch_norm_9.w_2 in Resources */, - C2C08EEA2142748D00C69DBF /* depthwise_conv2d_0.w_0 in Resources */, - C2C08EB82142748D00C69DBF /* batch_norm_16.w_0 in Resources */, - C2C08E5D2142748D00C69DBF /* conv2d_29.w_0 in Resources */, - C2C08E542142748D00C69DBF /* batch_norm_28.w_2 in Resources */, - C2C08EF62142748D00C69DBF /* conv2d_31.w_0 in Resources */, - C2C08E9A2142748D00C69DBF /* batch_norm_19.w_0 in Resources */, - C2C08EEB2142748D00C69DBF /* batch_norm_10.b_0 in Resources */, - C2C08EC32142748D00C69DBF /* conv2d_30.b_0 in Resources */, - C2C08EED2142748D00C69DBF /* batch_norm_23.w_2 in Resources */, - C2C08E452142748D00C69DBF /* ssd_hand_model in Resources */, - C2C08F022142748D00C69DBF /* batch_norm_9.w_0 in Resources */, - C2C08EE12142748D00C69DBF /* depthwise_conv2d_3.w_0 in Resources */, - C2C08EC22142748D00C69DBF /* conv2d_7.w_0 in Resources */, - C2C08EC12142748D00C69DBF /* conv2d_24.b_0 in Resources */, - C2C08E7A2142748D00C69DBF /* batch_norm_23.b_0 in Resources */, - C2C08EC52142748D00C69DBF /* batch_norm_29.w_0 in Resources */, - C2C08ED12142748D00C69DBF /* conv2d_3.w_0 in Resources */, - C2C08E4D2142748D00C69DBF /* batch_norm_26.b_0 in Resources */, - C2C08F0B2142748D00C69DBF /* batch_norm_8.w_1 in Resources */, - C2C08EC62142748D00C69DBF /* conv2d_6.w_0 in Resources */, - C2C08F0A2142748D00C69DBF /* batch_norm_31.w_2 in Resources */, - C2C08E702142748D00C69DBF /* batch_norm_20.b_0 in Resources */, - C2C08EBF2142748D00C69DBF /* batch_norm_14.w_0 in Resources */, - C2C08E482142748D00C69DBF /* model in Resources */, - C2C08EAC2142748D00C69DBF /* batch_norm_25.w_1 in Resources */, - C2C08EB42142748D00C69DBF /* conv2d_4.w_0 in Resources */, - C2C08F032142748D00C69DBF /* depthwise_conv2d_4.w_0 in Resources */, - C2C08E622142748D00C69DBF /* __model__ in Resources */, - C2C08E472142748D00C69DBF /* params in Resources */, - C2C08E502142748D00C69DBF /* batch_norm_15.w_2 in Resources */, - C2C08ECB2142748D00C69DBF /* batch_norm_16.w_1 in Resources */, - C2C08E632142748D00C69DBF /* batch_norm_7.w_1 in Resources */, - C2C08E942142748D00C69DBF /* batch_norm_30.w_0 in Resources */, - C2C08E5B2142748D00C69DBF /* depthwise_conv2d_9.w_0 in Resources */, - C2C08ECA2142748D00C69DBF /* batch_norm_8.b_0 in Resources */, - C2C08EDB2142748D00C69DBF /* batch_norm_13.w_0 in Resources */, - C2C08E412142748D00C69DBF /* model in Resources */, - C23717892148E5A50092444E /* ar_params in Resources */, - C2C08EE22142748D00C69DBF /* batch_norm_13.b_0 in Resources */, - C2C08E952142748D00C69DBF /* batch_norm_24.w_0 in Resources */, - C2C08F072142748D00C69DBF /* batch_norm_16.b_0 in Resources */, - C2C08ED72142748D00C69DBF /* batch_norm_0.w_2 in Resources */, - C2C08E7E2142748D00C69DBF /* batch_norm_11.w_2 in Resources */, - C2C08EB92142748D00C69DBF /* batch_norm_4.w_2 in Resources */, - C2C08EE72142748D00C69DBF /* conv2d_22.w_0 in Resources */, - C2C08EC02142748D00C69DBF /* batch_norm_28.w_0 in Resources */, - C2C08EC82142748D00C69DBF /* batch_norm_15.w_0 in Resources */, - C2C08F012142748D00C69DBF /* batch_norm_28.b_0 in Resources */, - C2C08E692142748D00C69DBF /* batch_norm_24.b_0 in Resources */, - C2C08E3B2142748D00C69DBF /* synset.txt in Resources */, - C2C08E892142748D00C69DBF /* batch_norm_22.w_1 in Resources */, - C2C08E772142748D00C69DBF /* batch_norm_0.w_0 in Resources */, - C2C08EA72142748D00C69DBF /* conv2d_9.w_0 in Resources */, - C2C08E9C2142748D00C69DBF /* batch_norm_32.w_1 in Resources */, - C2C08EA02142748D00C69DBF /* batch_norm_18.w_1 in Resources */, - C2C08F0E2142748D00C69DBF /* batch_norm_24.w_2 in Resources */, - C2C08EF42142748D00C69DBF /* conv2d_25.w_0 in Resources */, - C2C08E962142748D00C69DBF /* conv2d_28.b_0 in Resources */, - C2C08ED22142748D00C69DBF /* batch_norm_2.w_2 in Resources */, - C2C08ED62142748D00C69DBF /* depthwise_conv2d_10.w_0 in Resources */, - C2C08EBC2142748D00C69DBF /* batch_norm_17.w_1 in Resources */, - C2C08E862142748D00C69DBF /* batch_norm_2.b_0 in Resources */, - C2C08EF22142748D00C69DBF /* depthwise_conv2d_5.w_0 in Resources */, - C2C08EB02142748D00C69DBF /* batch_norm_5.w_2 in Resources */, - C23717882148E5A50092444E /* ar_model in Resources */, - C2C08E512142748D00C69DBF /* batch_norm_29.w_2 in Resources */, - C2C08E6E2142748D00C69DBF /* conv2d_10.w_0 in Resources */, - C2C08E8D2142748D00C69DBF /* batch_norm_34.w_0 in Resources */, - C2C08E642142748D00C69DBF /* batch_norm_6.w_1 in Resources */, - C2C08EAB2142748D00C69DBF /* batch_norm_19.w_1 in Resources */, - C2C08F002142748D00C69DBF /* conv2d_24.w_0 in Resources */, - C2C08EAD2142748D00C69DBF /* batch_norm_31.w_1 in Resources */, - C2C08EFA2142748D00C69DBF /* batch_norm_26.w_2 in Resources */, - C2C08F0D2142748D00C69DBF /* batch_norm_30.w_2 in Resources */, - C2C08E922142748D00C69DBF /* batch_norm_5.b_0 in Resources */, - C2C08E822142748D00C69DBF /* batch_norm_21.w_1 in Resources */, - C2C08ECE2142748D00C69DBF /* conv2d_2.w_0 in Resources */, - C2C08E7D2142748D00C69DBF /* batch_norm_0.w_1 in Resources */, - C2C08F0F2142748D00C69DBF /* batch_norm_18.w_2 in Resources */, - C2C08E682142748D00C69DBF /* conv2d_28.w_0 in Resources */, - C2C08E802142748D00C69DBF /* conv2d_12.w_0 in Resources */, - C2C08E752142748D00C69DBF /* batch_norm_21.b_0 in Resources */, - C2C08ED82142748D00C69DBF /* conv2d_22.b_0 in Resources */, - C2C08E552142748D00C69DBF /* batch_norm_14.w_2 in Resources */, - C2C08E6D2142748D00C69DBF /* batch_norm_1.w_0 in Resources */, - C2C08EF52142748D00C69DBF /* batch_norm_29.b_0 in Resources */, - C2C08E912142748D00C69DBF /* batch_norm_33.w_1 in Resources */, - C2C08F052142748D00C69DBF /* conv2d_32.w_0 in Resources */, - C2C08E732142748D00C69DBF /* batch_norm_3.w_1 in Resources */, - C2C08ED32142748D00C69DBF /* depthwise_conv2d_12.w_0 in Resources */, - C2C08F092142748D00C69DBF /* batch_norm_25.w_2 in Resources */, - C2C08E5F2142748D00C69DBF /* conv2d_15.w_0 in Resources */, - C2C08E5A2142748D00C69DBF /* batch_norm_4.w_0 in Resources */, - C2C08EDD2142748D00C69DBF /* conv2d_23.b_0 in Resources */, - C2C08E712142748D00C69DBF /* batch_norm_13.w_2 in Resources */, - C2C08EDE2142748D00C69DBF /* batch_norm_1.w_2 in Resources */, - C2C08EDA2142748D00C69DBF /* batch_norm_12.w_0 in Resources */, - C2C08E812142748D00C69DBF /* batch_norm_3.w_0 in Resources */, - C2C08EA42142748D00C69DBF /* batch_norm_27.w_0 in Resources */, - C2C08ECC2142748D00C69DBF /* batch_norm_12.w_1 in Resources */, - C2C08E592142748D00C69DBF /* batch_norm_6.w_0 in Resources */, - C2C08E3D2142748D00C69DBF /* hand.jpg in Resources */, - C2C08E422142748D00C69DBF /* genet_params in Resources */, - C2C08F122142748D00C69DBF /* conv2d_33.w_0 in Resources */, - C2C08F132142748D00C69DBF /* depthwise_conv2d_7.w_0 in Resources */, + FCBCCC522122EEDC00D94F7E /* ssd_hand_params in Resources */, + FCEEE7D4210627A000444BEC /* banana.jpeg in Resources */, + FC918193211DC70500B6F354 /* iphone.JPG in Resources */, + FCDFD41B211D91C7005AB38B /* synset.txt in Resources */, FC039B8720E11C550081E9F8 /* Main.storyboard in Resources */, - C2C08EFF2142748D00C69DBF /* conv2d_30.w_0 in Resources */, - C2C08F062142748D00C69DBF /* conv2d_26.w_0 in Resources */, + FCA3A16121313E1F00084FE5 /* hand.jpg in Resources */, + FC8CFEE62135452C0094D569 /* genet_params in Resources */, + FCBCCC532122EEDC00D94F7E /* ssd_hand_model in Resources */, + FC9A19E72148C38400CD9CBF /* ar_model in Resources */, + FC9A19E82148C38400CD9CBF /* ar_params in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1188,8 +359,11 @@ buildActionMask = 2147483647; files = ( FC039B8420E11C550081E9F8 /* ViewController.swift in Sources */, + FC803BCE214D27930094B8E5 /* VideoCapture.swift in Sources */, FC013928210204A3008100E3 /* PreProcessKernel.metal in Sources */, + FCF437E8214B6DDB00943429 /* MultiPredictViewController.swift in Sources */, FCBCCC552122EF5500D94F7E /* MetalHelper.swift in Sources */, + FC803BCD214D27930094B8E5 /* FPSCounter.swift in Sources */, FC039B8220E11C550081E9F8 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1338,10 +512,10 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6K8JTBT3MF; + DEVELOPMENT_TEAM = A798K58VVL; ENABLE_BITCODE = NO; INFOPLIST_FILE = "paddle-mobile-demo/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1365,10 +539,10 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6K8JTBT3MF; + DEVELOPMENT_TEAM = A798K58VVL; ENABLE_BITCODE = NO; INFOPLIST_FILE = "paddle-mobile-demo/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/Base.lproj/Main.storyboard b/metal/paddle-mobile-demo/paddle-mobile-demo/Base.lproj/Main.storyboard index a5efadeb97ccc41449dc32a2c1dfcdfcf9fceac5..69ee21170dc5ff64a759f625799b9e6d406b930c 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/Base.lproj/Main.storyboard +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/Base.lproj/Main.storyboard @@ -11,6 +11,34 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -20,9 +48,9 @@ - + - + @@ -159,11 +192,12 @@ - + + @@ -175,10 +209,12 @@ + + @@ -195,11 +231,12 @@ + - + diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/MultiPredictViewController.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/MultiPredictViewController.swift new file mode 100644 index 0000000000000000000000000000000000000000..6224322e336b5efdef00010bb604406f564b54bd --- /dev/null +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/MultiPredictViewController.swift @@ -0,0 +1,66 @@ +// +// Multi-Predict-ViewController.swift +// paddle-mobile-demo +// +// Created by liuRuiLong on 2018/9/14. +// Copyright © 2018年 orange. All rights reserved. +// + +import UIKit +import paddle_mobile + +class MultiPredictViewController: UIViewController { + var runner1: Runner! + var runner2: Runner! + override func viewDidLoad() { + super.viewDidLoad() + let mobileNet = MobileNet_ssd_hand.init(device: MetalHelper.shared.device) + let genet = Genet.init(device: MetalHelper.shared.device) + runner1 = Runner.init(inNet: mobileNet, commandQueue: MetalHelper.shared.queue, inPlatform: .GPU) + let queue2 = MetalHelper.shared.device.makeCommandQueue() + + runner2 = Runner.init(inNet: genet, commandQueue: MetalHelper.shared.queue, inPlatform: .GPU) + + + + + + + } + + @IBAction func predictAct(_ sender: Any) { + let success = self.runner2.load() +// DispatchQueue.global().async { + let image1 = UIImage.init(named: "hand.jpg") +// let success = self.runner2.load() +// if success { +// for i in 0..<10000 { +// print(i) +// self.runner2.predict(cgImage: image1!.cgImage!, completion: { (success, res) in +// print("result1: ") +//// print(res) +// }) +// } +// } else { +// print("load failed") +// } +// self.runner1.clear() +// } +// return +// DispatchQueue.global().async { +//// sleep(1) +// let image1 = UIImage.init(named: "banana.jpeg") +//// if success { +// for _ in 0..<10 { +// self.runner2.predict(cgImage: image1!.cgImage!, completion: { (success, res) in +// print("result2: ") +// print(res) +// }) +// } +//// } else { +//// print("load failed") +//// } +//// self.runner2.clear() +// } + } +} diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/VideoCapture/FPSCounter.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/VideoCapture/FPSCounter.swift new file mode 100644 index 0000000000000000000000000000000000000000..f9e841f9c2a3060e775726023b6d5cfc3eeb679d --- /dev/null +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/VideoCapture/FPSCounter.swift @@ -0,0 +1,31 @@ + + +import Foundation +import QuartzCore + +public class FPSCounter { + private(set) public var fps: Double = 0 + + var frames = 0 + var startTime: CFTimeInterval = 0 + + public func start() { + frames = 0 + startTime = CACurrentMediaTime() + } + + public func frameCompleted() { + frames += 1 + let now = CACurrentMediaTime() + let elapsed = now - startTime + if elapsed > 0.1 { + let current = Double(frames) / elapsed + let smoothing = 0.75 + fps = smoothing*fps + (1 - smoothing)*current + if elapsed > 1 { + frames = 0 + startTime = CACurrentMediaTime() + } + } + } +} diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/VideoCapture/VideoCapture.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/VideoCapture/VideoCapture.swift new file mode 100644 index 0000000000000000000000000000000000000000..5bbd33927a6a76fd3dfc5fb54c6a876663ffba33 --- /dev/null +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/VideoCapture/VideoCapture.swift @@ -0,0 +1,215 @@ + +import UIKit +import Metal +import CoreVideo +import AVFoundation + +@available(iOS 10.0, *) +@objc public protocol VideoCaptureDelegate: NSObjectProtocol { + @objc optional func videoCapture(_ capture: VideoCapture, didCaptureSampleBuffer sampleBuffer: CMSampleBuffer, timestamp: CMTime) + @objc optional func videoCapture(_ capture: VideoCapture, didCaptureVideoTexture texture: MTLTexture?, timestamp: CMTime) + @objc optional func videoCapture(_ capture: VideoCapture, didCapturePhoto previewImage: UIImage?) + @objc optional func videoCapture(_ capture: VideoCapture, didCapturePhotoTexture texture: MTLTexture?) +} + +/** + Simple interface to the iPhone's camera. +*/ +@available(iOS 10.0, *) +public class VideoCapture: NSObject { + public var previewLayer: AVCaptureVideoPreviewLayer? + public weak var delegate: VideoCaptureDelegate? + public var fps = -1 + private let device: MTLDevice? + private let videoOrientation: AVCaptureVideoOrientation + private var textureCache: CVMetalTextureCache? + private let captureSession = AVCaptureSession() + private let videoOutput = AVCaptureVideoDataOutput() + private let photoOutput = AVCapturePhotoOutput() + private let queue = DispatchQueue(label: "net.machinethink.camera-queue") + private var lastTimestamp = CMTime() + private let cameraPosition: AVCaptureDevice.Position + public init(device: MTLDevice? = nil, orientation: AVCaptureVideoOrientation = .portrait, position: AVCaptureDevice.Position = .back) { + self.device = device + self.videoOrientation = orientation + self.cameraPosition = position + super.init() + } + + public func setUp(sessionPreset: AVCaptureSession.Preset = .medium, + completion: @escaping (Bool) -> Void) { + queue.async { + let success = self.setUpCamera(sessionPreset: sessionPreset) + DispatchQueue.main.async { + completion(success) + } + } + } + + func fontCamera() -> AVCaptureDevice? { + let deveices = AVCaptureDevice.DiscoverySession.init(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .front).devices + return deveices.first + + } + + func setUpCamera(sessionPreset: AVCaptureSession.Preset) -> Bool { + if let inDevice = device{ + guard CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, inDevice, nil, &textureCache) == kCVReturnSuccess else { + print("Error: could not create a texture cache") + return false + } + } + + captureSession.beginConfiguration() + captureSession.sessionPreset = sessionPreset + + var oCaptureDevice: AVCaptureDevice? + switch cameraPosition { + case .back: + oCaptureDevice = AVCaptureDevice.default(for: AVMediaType.video) + break + case .front: + oCaptureDevice = fontCamera() + break + default: + break + } + + guard let captureDevice = oCaptureDevice else { + print("Error: no video devices available") + return false + } + + guard let videoInput = try? AVCaptureDeviceInput(device: captureDevice) else { + print("Error: could not create AVCaptureDeviceInput") + return false + } + + if captureSession.canAddInput(videoInput) { + captureSession.addInput(videoInput) + } + + let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) + previewLayer.videoGravity = AVLayerVideoGravity.resizeAspect + previewLayer.connection?.videoOrientation = self.videoOrientation + self.previewLayer = previewLayer + + let settings: [String : Any] = [ + kCVPixelBufferPixelFormatTypeKey as String: NSNumber(value: kCVPixelFormatType_32BGRA) + ] + + videoOutput.videoSettings = settings + videoOutput.alwaysDiscardsLateVideoFrames = true + videoOutput.setSampleBufferDelegate(self, queue: queue) + if captureSession.canAddOutput(videoOutput) { + captureSession.addOutput(videoOutput) + } + + // We want the buffers to be in portrait orientation otherwise they are + // rotated by 90 degrees. Need to set this _after_ addOutput()! + videoOutput.connection(with: AVMediaType.video)?.videoOrientation = self.videoOrientation + + if captureSession.canAddOutput(photoOutput) { + captureSession.addOutput(photoOutput) + } + + captureSession.commitConfiguration() + return true + } + + public func start() { + if !captureSession.isRunning { + captureSession.startRunning() + } + } + + public func stop() { + if captureSession.isRunning { + captureSession.stopRunning() + } + } + + /* Captures a single frame of the camera input. */ + public func capturePhoto() { + let settings = AVCapturePhotoSettings(format: [kCVPixelBufferPixelFormatTypeKey as String: NSNumber(value: kCVPixelFormatType_32BGRA)]) + settings.previewPhotoFormat = [ + kCVPixelBufferPixelFormatTypeKey as String: settings.__availablePreviewPhotoPixelFormatTypes[0], + kCVPixelBufferWidthKey as String: 480, + kCVPixelBufferHeightKey as String: 360, + ] + photoOutput.capturePhoto(with: settings, delegate: self) + } + + func convertToMTLTexture(sampleBuffer: CMSampleBuffer?) -> MTLTexture? { + if let textureCache = textureCache, let sampleBuffer = sampleBuffer, let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) { + let width = CVPixelBufferGetWidth(imageBuffer) + let height = CVPixelBufferGetHeight(imageBuffer) + var texture: CVMetalTexture? + CVMetalTextureCacheCreateTextureFromImage(kCFAllocatorDefault, textureCache, imageBuffer, nil, .bgra8Unorm, width, height, 0, &texture) + if let texture = texture { + return CVMetalTextureGetTexture(texture) + } + } + return nil + } + + func convertToUIImage(sampleBuffer: CMSampleBuffer?) -> UIImage? { + if let sampleBuffer = sampleBuffer, + let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) { + let width = CVPixelBufferGetWidth(imageBuffer) + let height = CVPixelBufferGetHeight(imageBuffer) + let rect = CGRect(x: 0, y: 0, width: CGFloat(width), height: CGFloat(height)) + let ciImage = CIImage(cvPixelBuffer: imageBuffer) + let ciContext = CIContext(options: nil) + if let cgImage = ciContext.createCGImage(ciImage, from: rect) { + return UIImage(cgImage: cgImage) + } + } + return nil + } +} + +extension VideoCapture: AVCaptureVideoDataOutputSampleBufferDelegate { + public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { + // Because lowering the capture device's FPS looks ugly in the preview, + // we capture at full speed but only call the delegate at its desired + // framerate. If `fps` is -1, we run at the full framerate. + let timestamp = CMSampleBufferGetPresentationTimeStamp(sampleBuffer) + let deltaTime = timestamp - lastTimestamp + if fps == -1 || deltaTime >= CMTimeMake(1, Int32(fps)) { + lastTimestamp = timestamp + self.delegate?.videoCapture?(self, didCaptureSampleBuffer: sampleBuffer, timestamp: timestamp) + if self.delegate?.responds(to: #selector(VideoCaptureDelegate.videoCapture(_:didCaptureVideoTexture:timestamp:))) ?? false{ + let texture = convertToMTLTexture(sampleBuffer: sampleBuffer) + delegate?.videoCapture?(self, didCaptureVideoTexture: texture, timestamp: timestamp) + } + } + } + + public func captureOutput(_ output: AVCaptureOutput, didDrop sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { + print("dropped frame") + } +} + +extension VideoCapture: AVCapturePhotoCaptureDelegate { + public func photoOutput(_ captureOutput: AVCapturePhotoOutput, + didFinishProcessingPhoto photoSampleBuffer: CMSampleBuffer?, + previewPhoto previewPhotoSampleBuffer: CMSampleBuffer?, + resolvedSettings: AVCaptureResolvedPhotoSettings, + bracketSettings: AVCaptureBracketedStillImageSettings?, + error: Error?) { + var imageTexture: MTLTexture? + var previewImage: UIImage? + if error == nil { + if self.delegate?.responds(to: #selector(VideoCaptureDelegate.videoCapture(_:didCapturePhotoTexture:))) ?? false{ + imageTexture = convertToMTLTexture(sampleBuffer: photoSampleBuffer) + self.delegate?.videoCapture?(self, didCapturePhotoTexture: imageTexture) + } + + if self.delegate?.responds(to: #selector(VideoCaptureDelegate.videoCapture(_:didCapturePhoto:))) ?? false{ + previewImage = convertToUIImage(sampleBuffer: previewPhotoSampleBuffer) + self.delegate?.videoCapture?(self, didCapturePhoto: previewImage) + } + } + } +} diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift index 3bc9e1668750af53d53bb14fd05c363c96e924c0..006bfa747021ce600960a2c7eff8cb25ab42a659 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift @@ -14,27 +14,32 @@ import UIKit import MetalKit +import CoreMedia import paddle_mobile import MetalPerformanceShaders -let platform: Platform = .GPU -let threadSupport = [1] +var platform: Platform = .GPU +let threadSupport: [(Platform, String)] = [(.GPU, "GPU"), (.CPU, "CPU")] -let modelHelperMap: [SupportModel : Runner] = [.mobilenet_ssd : Runner.init(inNet: MobileNet_ssd_hand.init(device: MetalHelper.shared.device), commandQueue: MetalHelper.shared.queue, inPlatform: platform), +//.mobilenet_ssd : Runner.init(inNet: MobileNet_ssd_hand.init(device: MetalHelper.shared.device), commandQueue: MetalHelper.shared.queue, inPlatform: platform), +let modelHelperMap: [SupportModel : Runner] = [ .genet : Runner.init(inNet: Genet.init(device: MetalHelper.shared.device), commandQueue: MetalHelper.shared.queue, inPlatform: platform), .mobilenet_ssd_ar : Runner.init(inNet: MobileNet_ssd_AR.init(device: MetalHelper.shared.device), commandQueue: MetalHelper.shared.queue, inPlatform: platform)] //, .genet : Genet.init() //let modelHelperMap: [SupportModel : Net] = [.mobilenet : MobileNet.init(), .mobilenet_ssd : MobileNet_ssd_hand.init()] +let netSupport: [SupportModel : Net] = [.genet : Genet.init(device: MetalHelper.shared.device), .mobilenet_ssd_ar : MobileNet_ssd_AR.init(device: MetalHelper.shared.device)] + enum SupportModel: String{ // case mobilenet = "mobilenet" - case mobilenet_ssd = "mobilenetssd" +// case mobilenet_ssd = "mobilenetssd" case genet = "genet" case mobilenet_ssd_ar = "mobilenetssd_ar" static func supportedModels() -> [SupportModel] { - //.mobilenet, - return [.mobilenet_ssd, .genet, .mobilenet_ssd_ar] + // .mobilenet, + // .mobilenet_ssd, + return [.genet, .mobilenet_ssd_ar] } } @@ -44,24 +49,36 @@ class ViewController: UIViewController { @IBOutlet weak var elapsedTimeLabel: UILabel! @IBOutlet weak var modelPickerView: UIPickerView! @IBOutlet weak var threadPickerView: UIPickerView! - + @IBOutlet weak var videoView: UIView! + var videoCapture: VideoCapture! + var selectImage: UIImage? var inputPointer: UnsafeMutablePointer? var modelType: SupportModel = SupportModel.supportedModels()[0] var toPredictTexture: MTLTexture? - var runner: Runner { - - get { - return modelHelperMap[modelType] ?! " has no this type " - } - set { - } - } + var runner: Runner! var threadNum = 1 @IBAction func loadAct(_ sender: Any) { + runner = Runner.init(inNet: netSupport[modelType]!, commandQueue: MetalHelper.shared.queue, inPlatform: platform) + + if platform == .CPU { + if inputPointer == nil { + inputPointer = runner.preproccess(image: selectImage!.cgImage!) + + } + } else if platform == .GPU { + if self.toPredictTexture == nil { + runner.getTexture(image: selectImage!.cgImage!) {[weak self] (texture) in + self?.toPredictTexture = texture + } + } + } else { + fatalError( " unsupport " ) + } + if runner.load() { print(" load success ! ") } else { @@ -81,7 +98,7 @@ class ViewController: UIViewController { } @IBAction func predictAct(_ sender: Any) { - let max = 1 + let max = 50 switch platform { case .GPU: guard let inTexture = toPredictTexture else { @@ -91,7 +108,7 @@ class ViewController: UIViewController { let startDate = Date.init() for i in 0.. #import -@interface PaddleMobile : NSObject +@interface PaddleMobileCPUResult: NSObject + +@property (assign, nonatomic, readonly) float *output; + +@property (assign, nonatomic, readonly) int outputSize; + +-(void)releaseOutput; + +@end + +@interface PaddleMobileCPU : NSObject /* 创建对象 @@ -42,25 +52,8 @@ andModelParamsLen:(size_t)combinedParamsLen andCombinedParamsBuf:(const uint8_t *)combinedParamsBuf; - -/* - * 进行预测, means 和 scale 为训练模型时的预处理参数, 如训练时没有做这些预处理则直接使用 predict - */ -- (NSArray *)predict:(CGImageRef)image - dim:(NSArray *)dim - means:(NSArray *)means - scale:(float)scale; - /* - * 预测输入 - * */ -- (NSArray *)predictInput:(float *)input - dim:(NSArray *)dim - means:(NSArray *)means - scale:(float)scale; - -/* - * 对图像进行预处理 + * 对图像进行预处理, 需要外部开辟 output 内存, 外部释放 output 内存 * */ -(void)preprocess:(CGImageRef)image output:(float *)output @@ -68,6 +61,22 @@ scale:(float)scale dim:(NSArray *)dim; +/* + * 预测预处理后的数据, 返回结果使用结束需要调用其 realseOutput 函数进行释放 + * */ +- (PaddleMobileCPUResult *)predictInput:(float *)input + dim:(NSArray *)dim; + +/* + 进行预测, means 和 scale 为训练模型时的预处理参数, 如训练时没有做这些预处理则直接使用 predict +*/ +- (NSArray *)predict:(CGImageRef)image dim:(NSArray *)dim means:(NSArray *)means scale:(float)scale; + +/* + 进行预测, 默认 means 为 0, scale 为 1.0 +*/ +- (NSArray *)predict:(CGImageRef)image dim:(NSArray *)dim; + /* 清理内存 */ diff --git a/metal/paddle-mobile/paddle-mobile/CPU/libpaddle-mobile.a b/metal/paddle-mobile/paddle-mobile/CPU/libpaddle-mobile.a deleted file mode 100644 index 9185441567a1ff772ac12aaf7b1f4e8ff1e64cc3..0000000000000000000000000000000000000000 Binary files a/metal/paddle-mobile/paddle-mobile/CPU/libpaddle-mobile.a and /dev/null differ diff --git a/metal/paddle-mobile/paddle-mobile/CPUCompute.h b/metal/paddle-mobile/paddle-mobile/CPUCompute.h index 0b0bc61602bc6383cd3a3dcad5163c030b4dcf7a..ed12dd60df4ea06944fdf4ff9b635fc12a99120e 100644 --- a/metal/paddle-mobile/paddle-mobile/CPUCompute.h +++ b/metal/paddle-mobile/paddle-mobile/CPUCompute.h @@ -16,6 +16,12 @@ #import + +@interface CPUResult: NSObject +@property (assign, nonatomic) float *output; +@property (assign, nonatomic) int outputSize; +@end + @interface NMSCompute: NSObject @property (assign, nonatomic) float scoreThredshold; @@ -34,6 +40,6 @@ @property (strong, nonatomic) NSArray *bboxDim; --(NSArray *)computeWithScore:(float *)score andBBoxs:(float *)bbox; +-(CPUResult *)computeWithScore:(float *)score andBBoxs:(float *)bbox; @end diff --git a/metal/paddle-mobile/paddle-mobile/CPUCompute.mm b/metal/paddle-mobile/paddle-mobile/CPUCompute.mm index be13105cb48ada269896f5dfde0df19b28a218d0..b97153765b46bb63d604d8845eee08d91283481d 100644 --- a/metal/paddle-mobile/paddle-mobile/CPUCompute.mm +++ b/metal/paddle-mobile/paddle-mobile/CPUCompute.mm @@ -21,6 +21,8 @@ #import + + struct NMSParam { float *score_data; @@ -282,9 +284,12 @@ void MultiClassNMSCompute(NMSParam *param) { param->output_size = output_size; } +@implementation CPUResult +@end + @implementation NMSCompute --(NSArray *)computeWithScore:(float *)score andBBoxs:(float *)bbox { +-(CPUResult *)computeWithScore:(float *)score andBBoxs:(float *)bbox { NMSParam param; param.box_data = bbox; param.score_data = score; @@ -306,12 +311,10 @@ void MultiClassNMSCompute(NMSParam *param) { } param.box_dim = box_dim; MultiClassNMSCompute(¶m); - NSMutableArray *output = [NSMutableArray arrayWithCapacity:param.output_size]; - for (int i = 0; i < param.output_size; ++i) { - [output addObject:[NSNumber numberWithFloat:param.output[i]]]; - } - delete param.output; - return output; + CPUResult *cr = [[CPUResult alloc] init]; + cr.output = param.output; + cr.outputSize = param.output_size; + return cr; } @end diff --git a/metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift b/metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift index 01c9c6c1fc277be1ed5fa6ace6774fc7f03f2de9..11bd1b67e06e3b2d4bcdb100b7afad3848644fc9 100644 --- a/metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift +++ b/metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift @@ -71,7 +71,128 @@ extension MTLDevice { return buffer! } + func texture2tensor_loop

(texture: MTLTexture, cb: ([Int], P)->Void) -> Void { + let bpR = texture.width * 4 * MemoryLayout

.size + let bpI = texture.height * bpR + let region = MTLRegion.init(origin: MTLOrigin.init(x: 0, y: 0, z: 0), size: MTLSize.init(width: texture.width, height: texture.height, depth: 1)) + for i in 0.. = UnsafeMutablePointer

.allocate(capacity: bpI) + texture.getBytes(pointer, bytesPerRow: bpR, bytesPerImage: bpI, from: region, mipmapLevel: 0, slice: i) + for tx in 0..(texture: MTLTexture, dim: [Int], transpose: [Int] = [0, 1, 2, 3]) -> [P] { + var tdim: [Int] = [1, 1, 1, 1] + for i in 0..(texture: MTLTexture, dim: [Int], transpose: [Int] = [0, 1, 2, 3]) -> [P] { + var tdim: [Int] = [1, 1, 1, 1] + for i in 0..(texture: MTLTexture, dim: [Int], transpose: [Int] = [0, 1, 2, 3]) -> [P] { + var tdim: [Int] = [1, 1, 1, 1] + for i in 0..(texture: MTLTexture, dim: [Int], transpose: [Int] = [0, 1, 2, 3]) -> [P] { + if dim.count == 3 { + return texture2tensor_3(texture: texture, dim: dim, transpose: transpose) + } else if dim.count == 2 { + return texture2tensor_2(texture: texture, dim: dim, transpose: transpose) + } else if dim.count == 1 { + return texture2tensor_1(texture: texture, dim: dim, transpose: transpose) + } var tdim: [Int] = [1, 1, 1, 1] for i in 0...size - let bpI = ndim[1] * bpR - let region = MTLRegion.init(origin: MTLOrigin.init(x: 0, y: 0, z: 0), size: MTLSize.init(width: ndim[2], height: ndim[1], depth: 1)) - for i in 0.. = UnsafeMutablePointer

.allocate(capacity: ndim[1] * ndim[2] * 4 * MemoryLayout

.size) - texture.getBytes(pointer, bytesPerRow: bpR, bytesPerImage: bpI, from: region, mipmapLevel: 0, slice: i) - - for h in 0...init(device: device, testParam: param) - concatKernel.test(cmdBuffer: buffer, param: param) - buffer.addCompletedHandler { (buffer) in - for i in 0...init(device: device, testParam: param) +// concatKernel.test(cmdBuffer: buffer, param: param) +// buffer.addCompletedHandler { (buffer) in +// for i in 0...init(device: device, testParam: param) - reshapeKernel.test(commandBuffer: buffer, testParam: param) - buffer.addCompletedHandler { (buffer) in - let _: Float32? = inTexture.logDesc() - let _: Float32? = outTexture.logDesc() - self.tensorPrint(tensor: input, dim: [2, 3, 4]) - let tx: [Float32] = self.device.texture2tensor(texture: outTexture, dim: [24]) - self.tensorPrint(tensor: tx, dim: [24]) - } - - - buffer.commit() +// let input: [Float32] = (0..<24).map { Float32($0) } +// let inTexture = device.tensor2texture(value: input, dim: [2, 3, 4]) +// let outTexture = device.tensor2texture(value: [Float32](), dim: [24]) +// let mp = ReshapeMetalParam.init( +// idim: (1, 2, 3, 4), +// itrans: (0, 1, 2, 3), +// odim: (1, 1, 1, 24), +// otrans: (0, 1, 2, 3) +// ) +// let param = ReshapeTestParam.init( +// inputTexture: inTexture, +// outputTexture: outTexture, +// param: mp +// ) +// let reshapeKernel = ReshapeKernel.init(device: device, testParam: param) +// reshapeKernel.test(commandBuffer: buffer, testParam: param) +// buffer.addCompletedHandler { (buffer) in +// let _: Float32? = inTexture.logDesc() +// let _: Float32? = outTexture.logDesc() +// self.tensorPrint(tensor: input, dim: [2, 3, 4]) +// let tx: [Float32] = self.device.texture2tensor(texture: outTexture, dim: [24]) +// self.tensorPrint(tensor: tx, dim: [24]) +// } +// +// +// buffer.commit() } public func testTranspose() { @@ -195,23 +195,23 @@ public class PaddleMobileUnitTest { // let tx: [Float32] = self.device.texture2tensor(texture: outputTexture, dim: [3, 3, 2, 4]) // self.tensorPrint(tensor: tx, dim: [3, 3, 2, 4]) // } - - let input: [Float32] = (0..<24).map { Float32($0) } - let inputTexture = device.tensor2texture(value: input, dim: [2, 3, 4]) - let outputTexture = device.tensor2texture(value: [Float](), dim: [3, 4, 2]) - let param = TransposeTestParam.init(inputTexture: inputTexture, outputTexture: outputTexture, iC: 4, oC: 2, axis: [0, 2, 3, 1]) - let transposeKernel = TransposeKernel.init(device: device, testParam: param) - - transposeKernel.test(commandBuffer: buffer, param: param) - - buffer.addCompletedHandler { (buffer) in - let _: Float32? = inputTexture.logDesc(header: "input texture", stridable: false) - let _: Float32? = outputTexture.logDesc(header: "output texture", stridable: false) - self.tensorPrint(tensor: input, dim: [2, 3, 4]) - let tx: [Float32] = self.device.texture2tensor(texture: outputTexture, dim: [3, 4, 2]) - self.tensorPrint(tensor: tx, dim: [3, 4, 2]) - } - +// +// let input: [Float32] = (0..<24).map { Float32($0) } +// let inputTexture = device.tensor2texture(value: input, dim: [2, 3, 4]) +// let outputTexture = device.tensor2texture(value: [Float](), dim: [3, 4, 2]) +// let param = TransposeTestParam.init(inputTexture: inputTexture, outputTexture: outputTexture, iC: 4, oC: 2, axis: [0, 2, 3, 1]) +// let transposeKernel = TransposeKernel.init(device: device, testParam: param) +// +// transposeKernel.test(commandBuffer: buffer, param: param) +// +// buffer.addCompletedHandler { (buffer) in +// let _: Float32? = inputTexture.logDesc(header: "input texture", stridable: false) +// let _: Float32? = outputTexture.logDesc(header: "output texture", stridable: false) +// self.tensorPrint(tensor: input, dim: [2, 3, 4]) +// let tx: [Float32] = self.device.texture2tensor(texture: outputTexture, dim: [3, 4, 2]) +// self.tensorPrint(tensor: tx, dim: [3, 4, 2]) +// } +// buffer.commit() } diff --git a/metal/paddle-mobile/paddle-mobile/Common/Types.swift b/metal/paddle-mobile/paddle-mobile/Common/Types.swift index 9e5a66dbd2f0ace1f4f727fffad6c94b9061b457..a1197ed2188a263af3c0819fec09b584af501dd3 100644 --- a/metal/paddle-mobile/paddle-mobile/Common/Types.swift +++ b/metal/paddle-mobile/paddle-mobile/Common/Types.swift @@ -243,7 +243,7 @@ extension Tensor: Variant { extension Texture: Variant { } -extension ResultHolder: Variant { +extension GPUResultHolder: Variant { } extension InputTexture: Variant { @@ -252,3 +252,43 @@ extension InputTexture: Variant { extension MTLTexture where Self: Variant { } + +class FetchHolder: Variant { + var resultBuffer: MTLBuffer? + var dim: [Int] + var capacity: Int + + init(inCapacity: Int, inDim: [Int]) { + capacity = inCapacity + dim = inDim + } + + func initBuffer(device: MTLDevice) { + resultBuffer = device.makeBuffer(length: capacity * 4, options: []) + } + + var result: UnsafeMutablePointer { + guard let inResultBuffer = resultBuffer else { + fatalError() + } + return inResultBuffer.contents().bindMemory(to: Float32.self, capacity: capacity) + } + +} + +extension FetchHolder: CustomStringConvertible, CustomDebugStringConvertible { + var description: String { + fatalError() +// return "\(result)" + } + + var debugDescription: String { + fatalError() +// return "\(result)" + } + + +} + + + diff --git a/metal/paddle-mobile/paddle-mobile/Genet.swift b/metal/paddle-mobile/paddle-mobile/Genet.swift index 0d582bc7d4f9e5bb7350ebb5ca4d0cd29b898941..d803d1e99537e3a24d1fae5a5653d680bd811ac2 100644 --- a/metal/paddle-mobile/paddle-mobile/Genet.swift +++ b/metal/paddle-mobile/paddle-mobile/Genet.swift @@ -46,8 +46,9 @@ public class Genet: Net { } } - override public func resultStr(res: [Float]) -> String { - return " \(Array(res.suffix(10))) ... " + override public func resultStr(res: ResultHolder) -> String { +// fatalError() + return " \(res.result![0]) ... " } } diff --git a/metal/paddle-mobile/paddle-mobile/MobileNet.swift b/metal/paddle-mobile/paddle-mobile/MobileNet.swift index a383a75d7216b3c574d3bd881d3b63774b9e36b8..7d10a920d15e751f29fce7f9f6be71cd6a2d6b69 100644 --- a/metal/paddle-mobile/paddle-mobile/MobileNet.swift +++ b/metal/paddle-mobile/paddle-mobile/MobileNet.swift @@ -42,9 +42,12 @@ class MobileNet: Net{ let labels = PreWords.init(fileName: "synset") - override public func resultStr(res: [Float]) -> String { + override public func resultStr(res: ResultHolder) -> String { + guard let resPointer = res.result else { + fatalError() + } var s: [String] = [] - res.top(r: 5).enumerated().forEach{ + (0.. String { + override public func resultStr(res: ResultHolder) -> String { return " \(res)" } - override func fetchResult(paddleMobileRes: ResultHolder) -> [Float32] { + override func fetchResult(paddleMobileRes: GPUResultHolder) -> ResultHolder { - guard let interRes = paddleMobileRes.intermediateResults else { - fatalError(" need have inter result ") - } - - guard let scores = interRes["Scores"], scores.count > 0, let score = scores[0] as? Texture else { - fatalError(" need score ") - } - - guard let bboxs = interRes["BBoxes"], bboxs.count > 0, let bbox = bboxs[0] as? Texture else { - fatalError() - } - - var scoreFormatArr: [Float32] = score.metalTexture.realNHWC(dim: (n: score.padToFourDim[0], h: score.padToFourDim[1], w: score.padToFourDim[2], c: score.padToFourDim[3])) -// print("score: ") -// print(scoreFormatArr.strideArray()) +// guard let interRes = paddleMobileRes.intermediateResults else { +// fatalError(" need have inter result ") +// } // - var bboxArr = bbox.metalTexture.float32Array() -// print("bbox: ") -// print(bboxArr.strideArray()) - - let nmsCompute = NMSCompute.init() - nmsCompute.scoreThredshold = 0.01 - nmsCompute.nmsTopK = 400 - nmsCompute.keepTopK = 200 - nmsCompute.nmsEta = 1.0 - nmsCompute.nmsThreshold = 0.45 - nmsCompute.background_label = 0; - - nmsCompute.scoreDim = [NSNumber.init(value: score.tensorDim[0]), NSNumber.init(value: score.tensorDim[1]), NSNumber.init(value: score.tensorDim[2])] - - nmsCompute.bboxDim = [NSNumber.init(value: bbox.tensorDim[0]), NSNumber.init(value: bbox.tensorDim[1]), NSNumber.init(value: bbox.tensorDim[2])] - guard let result = nmsCompute.compute(withScore: &scoreFormatArr, andBBoxs: &bboxArr) else { - fatalError( " result error " ) - } - - let output: [Float32] = result.map { $0.floatValue } - - - return output +// guard let scores = interRes["Scores"], scores.count > 0, let score = scores[0] as? Texture else { +// fatalError(" need score ") +// } +// +// guard let bboxs = interRes["BBoxes"], bboxs.count > 0, let bbox = bboxs[0] as? Texture else { +// fatalError() +// } +// +// var scoreFormatArr: [Float32] = score.metalTexture.realNHWC(dim: (n: score.padToFourDim[0], h: score.padToFourDim[1], w: score.padToFourDim[2], c: score.padToFourDim[3])) +//// print("score: ") +//// print(scoreFormatArr.strideArray()) +//// +// var bboxArr = bbox.metalTexture.float32Array() +//// print("bbox: ") +//// print(bboxArr.strideArray()) +// +// let nmsCompute = NMSCompute.init() +// nmsCompute.scoreThredshold = 0.01 +// nmsCompute.nmsTopK = 400 +// nmsCompute.keepTopK = 200 +// nmsCompute.nmsEta = 1.0 +// nmsCompute.nmsThreshold = 0.45 +// nmsCompute.background_label = 0; +// +// nmsCompute.scoreDim = [NSNumber.init(value: score.tensorDim[0]), NSNumber.init(value: score.tensorDim[1]), NSNumber.init(value: score.tensorDim[2])] +// +// nmsCompute.bboxDim = [NSNumber.init(value: bbox.tensorDim[0]), NSNumber.init(value: bbox.tensorDim[1]), NSNumber.init(value: bbox.tensorDim[2])] +// guard let result = nmsCompute.compute(withScore: &scoreFormatArr, andBBoxs: &bboxArr) else { +// fatalError( " result error " ) +// } +// +// let output: [Float32] = result.map { $0.floatValue } +// +// +// return output + fatalError() } diff --git a/metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift b/metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift index 106a1882ff9dd6edeff107f013c282346fd83977..c4307f22c179f549dfa352364f6baa38ac92bd97 100644 --- a/metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift +++ b/metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift @@ -30,50 +30,112 @@ public class MobileNet_ssd_AR: Net{ class MobilenetssdPreProccess: CusomKernel { init(device: MTLDevice) { let s = CusomKernel.Shape.init(inWidth: 160, inHeight: 160, inChannel: 3) - super.init(device: device, inFunctionName: "mobilent_ar_preprocess_half", outputDim: s, usePaddleMobileLib: false) + super.init(device: device, inFunctionName: "mobilent_ar_preprocess", outputDim: s, usePaddleMobileLib: false) } } - override public func resultStr(res: [Float]) -> String { - return " \(res)" + override public func resultStr(res: ResultHolder) -> String { + return " \(res.result![0])" } - override func fetchResult(paddleMobileRes: ResultHolder) -> [Float32] { - + override func fetchResult(paddleMobileRes: GPUResultHolder) -> ResultHolder { guard let interRes = paddleMobileRes.intermediateResults else { fatalError(" need have inter result ") } - guard let scores = interRes["Scores"], scores.count > 0, let score = scores[0] as? Texture else { + guard let scores = interRes["Scores"], scores.count > 0, let score = scores[0] as? FetchHolder else { fatalError(" need score ") } - guard let bboxs = interRes["BBoxes"], bboxs.count > 0, let bbox = bboxs[0] as? Texture else { + guard let bboxs = interRes["BBoxes"], bboxs.count > 0, let bbox = bboxs[0] as? FetchHolder else { fatalError() } - var scoreFormatArr: [Float32] = score.metalTexture.realNHWC(dim: (n: score.padToFourDim[0], h: score.padToFourDim[1], w: score.padToFourDim[2], c: score.padToFourDim[3])) - // print("score: ") - // print(scoreFormatArr.strideArray()) - // - var bboxArr = bbox.metalTexture.float32Array() - // print("bbox: ") - // print(bboxArr.strideArray()) +// let startDate = Date.init() + +// print("scoreFormatArr: ") +//print((0.. + originTexture.tensorDim = Dim.init(inDim: [originTexture.tensorDim[1] / 7, originTexture.tensorDim[0] * 7]) + + originTexture.dim = Dim.init(inDim: [1, 1, originTexture.dim[3] / 7, originTexture.dim[2] * 7]) + + originTexture.padToFourDim = Dim.init(inDim: [1, 1, originTexture.padToFourDim[3] / 7, originTexture.padToFourDim[2] * 7]) + + program.scope[output] = originTexture + + if i == 99 { + opDesc.attrs["axis"] = 0 + } else { + opDesc.attrs["shape"] = originTexture.tensorDim.dims.map { Int32($0) } + } + } - let output: [Float32] = result.map { $0.floatValue } - return output + for i in [58, 59, 88, 89, 95, 96, 68, 69, 78, 79] { + let opDesc = program.programDesc.blocks[0].ops[i] + let output = opDesc.outputs["Out"]!.first! + let v = program.scope[output]! + + + + let originTexture = v as! Texture + originTexture.tensorDim = Dim.init(inDim: [originTexture.tensorDim[1], originTexture.tensorDim[2]]) + opDesc.attrs["shape"] = originTexture.tensorDim.dims.map { Int32($0) } + } + + for i in [60, 101, 90, 97, 70, 80] { + let opDesc = program.programDesc.blocks[0].ops[i] + let output = opDesc.outputs["Out"]!.first! + let v = program.scope[output]! + let originTexture = v as! Texture + originTexture.tensorDim = Dim.init(inDim: [originTexture.tensorDim[1], originTexture.tensorDim[2]]) + opDesc.attrs["axis"] = (opDesc.attrs["axis"]! as! Int) - 1 + } + + for i in [102] { + let opDesc = program.programDesc.blocks[0].ops[i] + for output in opDesc.outputs["Out"]! { + let v = program.scope[output]! + let originTexture = v as! Texture + originTexture.tensorDim = Dim.init(inDim: [originTexture.tensorDim[1], originTexture.tensorDim[2]]) + } + opDesc.attrs["axis"] = (opDesc.attrs["axis"]! as! Int) - 1 + print(" split axis \(opDesc.attrs["axis"])") + } + // 99 } + } diff --git a/metal/paddle-mobile/paddle-mobile/Net.swift b/metal/paddle-mobile/paddle-mobile/Net.swift new file mode 100644 index 0000000000000000000000000000000000000000..1c90d04fe664c3a72e4e3cba66239208a1071581 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Net.swift @@ -0,0 +1,70 @@ +/* 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 class ResultHolder: NSObject { + @objc public let result: UnsafeMutablePointer? + @objc public let capacity: Int + + init(inResult: UnsafeMutablePointer?, inCapacity: Int) { + result = inResult + capacity = inCapacity + } + + public func releasePointer() { + result?.deinitialize(count: capacity) + result?.deallocate() + } +} + +public class Net: NSObject { + var except: Int = 0 + var means: [Float] = [] + var scale: Float = 0.0 + var dim: (n: Int, h: Int, w: Int, c: Int) = (n: 0, h: 0, w: 0, c: 0) + var preprocessKernel: CusomKernel? = nil + var paramPointer: UnsafeMutableRawPointer? = nil + var paramSize: Int = 0 + var modelPointer: UnsafeMutableRawPointer? = nil + var modelSize: Int = 0 + var modelPath: String = "" + var paramPath: String = "" + var modelDir: String = "" + @objc public init(device: MTLDevice,paramPointer: UnsafeMutableRawPointer, paramSize:Int, modePointer: UnsafeMutableRawPointer, modelSize: Int) { + self.paramPointer = paramPointer + self.paramSize = paramSize + self.modelPointer = modePointer + self.modelSize = modelSize + super.init() + } + + + public func resultStr(res: ResultHolder) -> String { + fatalError() + } + + func fetchResult(paddleMobileRes: GPUResultHolder) -> ResultHolder { + return ResultHolder.init(inResult: paddleMobileRes.resultPointer, inCapacity: paddleMobileRes.capacity) + } + + @objc public init(device: MTLDevice) { + super.init() + } + + func updateProgram(program: Program) { + + } +} diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Base/OpCreator.swift b/metal/paddle-mobile/paddle-mobile/Operators/Base/OpCreator.swift index 68763feef8e347cdfa3b7be5096aadc67fb93084..af7dc47df2a68068d47f2172a59222cfa41dc904 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Base/OpCreator.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Base/OpCreator.swift @@ -64,7 +64,8 @@ class OpCreator { gBilinearInterpType : BilinearInterpOp

.creat, gSplit : SplitOp

.creat, gShape : ShapeOp

.creat, - gFlatten : FlattenOp

.creat] + gFlatten : FlattenOp

.creat, + gConvAddPreluType : ConvAddPreluOp

.creat] private init(){} } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Base/Operator.swift b/metal/paddle-mobile/paddle-mobile/Operators/Base/Operator.swift index dded09dae7985829c062eac67f9df47cbcbd6084..01b6692c6e168c4c8636248c232f94a598152f33 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Base/Operator.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Base/Operator.swift @@ -19,6 +19,12 @@ protocol Fusion { static func fusionNode() -> Node static func change() -> [String : [(from: String, to: String)]] static func fusionType() -> String + static func needCheck() -> [(Int, String)] +} +extension Fusion { + static func needCheck() -> [(Int, String)] { + return [] + } } protocol Runable { @@ -26,6 +32,7 @@ protocol Runable { func runImpl(device: MTLDevice,buffer: MTLCommandBuffer) throws func delogOutput() func inputVariant() -> [String : [Variant]] + func computeMiddleResult(device: MTLDevice, buffer: MTLCommandBuffer) } extension Runable where Self: OperatorProtocol{ @@ -38,11 +45,16 @@ extension Runable where Self: OperatorProtocol{ } func inputVariant() -> [String : [Variant]] { - return [:] -// fatalError(" op \(type) need implement inputVariant") +// return [:] + fatalError(" op \(type) need implement inputVariant") + } + + func computeMiddleResult(device: MTLDevice, buffer: MTLCommandBuffer) { + fatalError(" need implement ") } func delogOutput() { + print(type + ": has no implementation" ) } } @@ -144,6 +156,7 @@ let gBilinearInterpType = "bilinear_interp" let gSplit = "split" let gShape = "shape" let gFlatten = "flatten" +let gConvAddPreluType = "conv_add_prelu" let opInfos = [gConvType : (inputs: ["Input"], outputs: ["Output"]), gBatchNormType : (inputs: ["X"], outputs: ["Y"]), @@ -169,5 +182,7 @@ let opInfos = [gConvType : (inputs: ["Input"], outputs: ["Out gBilinearInterpType : (inputs: ["X"], outputs: ["Out"]), gSplit : (inputs: ["X"], outputs: ["Out"]), gShape : (inputs: ["Input"], outputs: ["Out"]), - gFlatten : (inputs: ["X"], outputs: ["Out"]) + gFlatten : (inputs: ["X"], outputs: ["Out"]), + gConvAddPreluType : (inputs: ["Input"], outputs: ["Out"]) + ] diff --git a/metal/paddle-mobile/paddle-mobile/Operators/BatchNormOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/BatchNormOp.swift index cd7bebaf40204affc2009258af5894b7a2cc40ec..cd559e79ad6bc267ca88e857fb2def9a7968dc77 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/BatchNormOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/BatchNormOp.swift @@ -19,11 +19,14 @@ class BatchNormParam: OpParam { required init(opDesc: OpDesc, inScope: Scope) throws { do { input = try BatchNormParam.inputX(inputs: opDesc.inputs, from: inScope) + if input.transpose != [0, 2, 3, 1] { + fatalError("batch norm only accepts NHWC") + } output = try BatchNormParam.outputY(outputs: opDesc.outputs, from: inScope) - inputBias = try BatchNormParam.inputBiase(inputs: opDesc.paraInputs, from: inScope) - inputMean = try BatchNormParam.inputMean(inputs: opDesc.paraInputs, from: inScope) - inputScale = try BatchNormParam.inputScale(inputs: opDesc.paraInputs, from: inScope) - inputVariance = try BatchNormParam.inputVariance(inputs: opDesc.paraInputs, from: inScope) + bias = try BatchNormParam.getFirstTensor(key: "Bias", map: opDesc.paraInputs, from: inScope) + mean = try BatchNormParam.getFirstTensor(key: "Mean", map: opDesc.paraInputs, from: inScope) + scale = try BatchNormParam.getFirstTensor(key: "Scale", map: opDesc.paraInputs, from: inScope) + variance = try BatchNormParam.getFirstTensor(key: "Variance", map: opDesc.paraInputs, from: inScope) epsilon = try BatchNormParam.getAttr(key: "epsilon", attrs: opDesc.attrs) momentum = try BatchNormParam.getAttr(key: "momentum", attrs: opDesc.attrs) } catch let error { @@ -32,10 +35,10 @@ class BatchNormParam: OpParam { } let input: Texture

var output: Texture

- let inputBias: Tensor - let inputMean: Tensor - let inputScale: Tensor - let inputVariance: Tensor + let bias: Tensor

+ let mean: Tensor

+ let scale: Tensor

+ let variance: Tensor

let epsilon: Float let momentum: Float } @@ -53,9 +56,11 @@ class BatchNormOp: Operator, BatchNormParam throw error } } + + func delogOutput() { + print(" \(type) output: ") + let device = para.output.metalTexture!.device + let outputArray: [Float32] = device.texture2tensor(texture: para.output.metalTexture, dim: para.output.tensorDim.dims, transpose: para.output.transpose) + print(outputArray.strideArray()) + } } - - - - - diff --git a/metal/paddle-mobile/paddle-mobile/Operators/BilinearInterpOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/BilinearInterpOp.swift index e7f0db22312e8d49505513290bd21a6695d65790..f1277272a7b92aa9f27492b411fe289c00a35c8e 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/BilinearInterpOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/BilinearInterpOp.swift @@ -19,15 +19,15 @@ class BilinearInterpParam: OpParam { required init(opDesc: OpDesc, inScope: Scope) throws { do { input = try BilinearInterpParam.inputX(inputs: opDesc.inputs, from: inScope) -// if (input.transpose != [0, 2, 3, 1]) || (input.tensorDim.cout() != 4) { -// fatalError() -// } output = try BilinearInterpParam.outputOut(outputs: opDesc.outputs, from: inScope) out_h = try BilinearInterpParam.getAttr(key: "out_h", attrs: opDesc.attrs) out_w = try BilinearInterpParam.getAttr(key: "out_w", attrs: opDesc.attrs) } catch let error { throw error } + if (input.transpose != [0, 2, 3, 1]) || (input.tensorDim.cout() != 4) { + fatalError() + } } let input: Texture

var output: Texture

@@ -53,6 +53,10 @@ class BilinearInterpOp: Operator, Bili func delogOutput() { print(" \(type) output: ") + let device = para.output.metalTexture!.device + let outputArray: [Float32] = device.texture2tensor(texture: para.output.metalTexture, dim: para.output.tensorDim.dims, transpose: para.output.transpose) +// print(outputArray) + print(outputArray.strideArray()) } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/BoxcoderOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/BoxcoderOp.swift index d7c1aba2494479f30806f80f9ccefe943b5f7101..84d483cb7ab10a3548d22c54117e009a7515e523 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/BoxcoderOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/BoxcoderOp.swift @@ -27,6 +27,10 @@ class BoxcoderParam: OpParam { } catch let error { throw error } + assert(priorBox.tensorDim.cout() == 2) + assert(priorBoxVar.tensorDim.cout() == 2) + assert(targetBox.tensorDim.cout() == 3) + assert(output.tensorDim.cout() == 3) assert(priorBox.transpose == [0, 1, 2, 3]) assert(priorBoxVar.transpose == [0, 1, 2, 3]) assert(targetBox.transpose == [0, 1, 2, 3]) @@ -59,30 +63,19 @@ class BoxcoderOp: Operator, BoxcoderParam

func delogOutput() { print(" \(type) output: ") -// let priorBoxpadToFourDim = para.priorBox.padToFourDim -// let priorBoxArray: [Float32] = para.priorBox.metalTexture.realNHWC(dim: (n: priorBoxpadToFourDim[0], h: priorBoxpadToFourDim[1], w: priorBoxpadToFourDim[2], c: priorBoxpadToFourDim[3])) -// print(" prior box ") -// print(priorBoxArray.strideArray()) -// -// let priorBoxVarpadToFourDim = para.priorBoxVar.padToFourDim -// let priorBoxVarArray: [Float32] = para.priorBoxVar.metalTexture.realNHWC(dim: (n: priorBoxVarpadToFourDim[0], h: priorBoxVarpadToFourDim[1], w: priorBoxVarpadToFourDim[2], c: priorBoxVarpadToFourDim[3])) -// print(" prior box var ") -// print(priorBoxVarArray.strideArray()) -// -// let targetBoxpadToFourDim = para.targetBox.padToFourDim -// let targetBoxArray: [Float32] = para.targetBox.metalTexture.realNHWC(dim: (n: targetBoxpadToFourDim[0], h: targetBoxpadToFourDim[1], w: targetBoxpadToFourDim[2], c: targetBoxpadToFourDim[3])) -// print(" target box ") -// print(targetBoxArray.strideArray()) - - let targetBoxpadToFourDim = para.targetBox.padToFourDim - let targetBoxArray = para.targetBox.metalTexture.realNHWC(dim: (n: targetBoxpadToFourDim[0], h: targetBoxpadToFourDim[1], w: targetBoxpadToFourDim[2], c: targetBoxpadToFourDim[3])) + let device = para.output.metalTexture!.device + let pbv : [Float32] = device.texture2tensor(texture: para.priorBoxVar.metalTexture!, dim: para.priorBoxVar.tensorDim.dims, transpose: para.priorBoxVar.transpose) + let pb : [Float32] = device.texture2tensor(texture: para.priorBox.metalTexture!, dim: para.priorBox.tensorDim.dims, transpose: para.priorBox.transpose) + let tb : [Float32] = device.texture2tensor(texture: para.targetBox.metalTexture!, dim: para.targetBox.tensorDim.dims, transpose: para.targetBox.transpose) + let out : [Float32] = device.texture2tensor(texture: para.output.metalTexture!, dim: para.output.tensorDim.dims, transpose: para.output.transpose) + print(" prior box var ") + print(pbv.strideArray()) print(" target box ") - print(targetBoxArray.strideArray()) - - let padToFourDim = para.output.padToFourDim - let outputArray: [Float32] = para.output.metalTexture.realNHWC(dim: (n: padToFourDim[0], h: padToFourDim[1], w: padToFourDim[2], c: padToFourDim[3])) + print(tb.strideArray()) + print(" prior box ") + print(pb.strideArray()) print(" output ") - print(outputArray.strideArray()) + print(out.strideArray()) } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift index 1abdb66aa7bdf89759a5987e3dde523c1f1dcf41..0a30b2bbefbda9694a46d4e036548a6c680224a3 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift @@ -65,15 +65,10 @@ class ConcatOp: Operator, ConcatParam

>, Run func delogOutput() { print(" \(type) output: ") - let padToFourDim = para.output.padToFourDim - if para.output.transpose == [0, 1, 2, 3] { - let outputArray: [Float32] = para.output.metalTexture.realNHWC(dim: (n: padToFourDim[0], h: padToFourDim[1], w: padToFourDim[2], c: padToFourDim[3])) - print(outputArray.strideArray()) - } else if para.output.transpose == [0, 2, 3, 1] { - print(para.output.metalTexture.toTensor(dim: (n: padToFourDim[0], c: padToFourDim[1], h: padToFourDim[2], w: padToFourDim[3])).strideArray()) - } else { - fatalError(" not implemet") - } + + let device = para.output.metalTexture!.device + let outputArray: [Float32] = device.texture2tensor(texture: para.output.metalTexture, dim: para.output.tensorDim.dims, transpose: para.output.transpose) + print(outputArray.strideArray()) } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ConvAddPreluOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ConvAddPreluOp.swift new file mode 100644 index 0000000000000000000000000000000000000000..0a0fcc7d7934e1c3c7a48f6925105b02ec6d8fc9 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/ConvAddPreluOp.swift @@ -0,0 +1,101 @@ +/* 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 ConvAddPreluParam: OpParam { + typealias ParamPrecisionType = P + required init(opDesc: OpDesc, inScope: Scope) throws { + do { + filter = try ConvAddPreluParam.inputFilter(paraInputs: opDesc.paraInputs, from: inScope) + input = try ConvAddPreluParam.input(inputs: opDesc.inputs, from: inScope) + output = try ConvAddPreluParam.outputOut(outputs: opDesc.outputs, from: inScope) + stride = try ConvAddPreluParam.getAttr(key: "strides", attrs: opDesc.attrs) + paddings = try ConvAddPreluParam.getAttr(key: "paddings", attrs: opDesc.attrs) + dilations = try ConvAddPreluParam.getAttr(key: "dilations", attrs: opDesc.attrs) + groups = try ConvAddPreluParam.getAttr(key: "groups", attrs: opDesc.attrs) + alpha = try ConvAddPreluParam.paramInputAlpha(inputs: opDesc.paraInputs, from: inScope) + mode = try ConvAddPreluParam.getAttr(key: "mode", attrs: opDesc.attrs) + y = try ConvAddPreluParam.inputY(inputs: opDesc.paraInputs, from: inScope) + } catch let error { + throw error + } + } + + let input: Texture

+ let y: Tensor + let filter: Tensor + let mode: String + let alpha: Tensor

+ var output: Texture

+ let stride: [Int32] + let paddings: [Int32] + let dilations: [Int32] + let groups: Int +} + +class ConvAddPreluOp: Operator, ConvAddPreluParam

>, Runable, Creator, InferShaperable, Fusion{ + typealias OpType = ConvAddPreluOp

+ + static func fusionNode() -> Node { + let beginNode = Node.init(inType: gConvType) + _ = beginNode + --> Node.init(inType: gElementwiseAddType) --> Node.init(inType: gPreluType) + return beginNode + } + + static func change() -> [String : [(from: String, to: String)]] { + return [:] + } + + static func fusionType() -> String { + return gConvAddPreluType + } + + func inferShape() { + let inDims = para.input.dim + let filterDim = para.filter.dim + let strides = para.stride + let paddings = para.paddings + let dilations = para.dilations + + var outDim = [inDims[0]] + for i in 0..: OpParam{ - var output: Texture

+ var output: FetchHolder let input: Texture

let scope: Scope required init(opDesc: OpDesc, inScope: Scope) throws { scope = inScope do { input = try FetchParam.inputX(inputs: opDesc.inputs, from: inScope) - output = input + output = FetchHolder.init(inCapacity: input.numel(), inDim: input.tensorDim.dims) + scope.setOutput(output: output) } catch let error { throw error } @@ -34,14 +35,40 @@ class FetchParam: OpParam{ class FetchKernel: Kernel, Computable { func compute(commandBuffer: MTLCommandBuffer, param: FetchParam

) throws { + guard let encoder = commandBuffer.makeComputeCommandEncoder() else { + throw PaddleMobileError.predictError(message: " encode is nil") + } + encoder.setTexture(param.input.metalTexture, index: 0) + encoder.setBuffer(param.output.resultBuffer!, offset: 0, index: 0) + encoder.dispatch(computePipline: pipline, outTexture: param.input.metalTexture) + encoder.endEncoding() } required init(device: MTLDevice, param: FetchParam

) { - super.init(device: device, inFunctionName: "place_holder") + param.output.initBuffer(device: device) + if computePrecision == .Float16 { + if param.input.transpose == [0, 2, 3, 1] { + super.init(device: device, inFunctionName: "fetch_half") + } else { +// fatalError(" not support ") + super.init(device: device, inFunctionName: "fetch_placeholder_half") + print(" not support ") + } + } else if computePrecision == .Float32 { + if param.input.transpose == [0, 2, 3, 1] { + super.init(device: device, inFunctionName: "fetch") + } else { + print(" not support ") + super.init(device: device, inFunctionName: "fetch_placeholder") +// fatalError(" not support ") + } + } else { + fatalError(" not support ") + } } } -class FetchOp: Operator< FetchKernel

, FetchParam

>, Runable, Creator, InferShaperable{ +class FetchOp: Operator< FetchKernel

, FetchParam

>, Runable, Creator, InferShaperable { typealias OpType = FetchOp

@@ -50,7 +77,11 @@ class FetchOp: Operator< FetchKernel

, FetchParam

>, Runab } func runImpl(device: MTLDevice, buffer: MTLCommandBuffer) throws { - scope.setOutput(output: para.output) + do { + try kernel.compute(commandBuffer: buffer, param: para) + } catch let error { + throw error + } } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/FlattenOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/FlattenOp.swift index 70dd1c0fc8d47e336bf0d4d2695caa0fc7846ca9..0bf9ad85c61478431b1cff7ae676f1ac092b8a5f 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/FlattenOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/FlattenOp.swift @@ -14,7 +14,24 @@ import Foundation -class FlattenOp: Operator, ReshapeParam

>, Runable, Creator, InferShaperable{ +class FlattenParam: OpParam { + typealias ParamPrecisionType = P + required init(opDesc: OpDesc, inScope: Scope) throws { + do { + input = try FlattenParam.inputX(inputs: opDesc.inputs, from: inScope) + output = try FlattenParam.outputOut(outputs: opDesc.outputs, from: inScope) + axis = try FlattenParam.getAttr(key: "axis", attrs: opDesc.attrs) + } catch let error { + throw error + } + } + let input: Texture

+ var output: Texture

+ let axis: Int +} + + +class FlattenOp: Operator, FlattenParam

>, Runable, Creator, InferShaperable{ typealias OpType = FlattenOp

@@ -32,6 +49,9 @@ class FlattenOp: Operator, ReshapeParam

>, func delogOutput() { print(" \(type) output: ") + let device = para.output.metalTexture!.device + let outputArray: [Float32] = device.texture2tensor(texture: para.output.metalTexture, dim: para.output.tensorDim.dims, transpose: para.output.transpose) + print(outputArray.strideArray()) } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift index b80a47516e083b3f5f303202b0e5f08d6c796a65..dad8d0c6ac2e5a93273573473c700179f8b90a37 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift @@ -15,20 +15,21 @@ import Foundation class BatchNormKernel: Kernel, Computable { -// var newScale: MTLBuffer -// var newBias: MTLBuffer -// required init(device: MTLDevice, param: BatchNormParam

) { -// guard let newScale = device.makeBuffer(length: param.inputScale.buffer.length) else { -// fatalError() -// } -// -// guard let newBias = device.makeBuffer(length: param.inputBias.buffer.length) else { -// fatalError() -// } -// self.newScale = newScale -// self.newBias = newBias -// + let count = param.variance.dim.numel() + let varianceP = param.variance.data.pointer + let meanP = param.mean.data.pointer + let scaleP = param.scale.data.pointer + let biasP = param.bias.data.pointer + for i in 0..: Kernel, Computable { } else { fatalError() } -// -// let varianceBuffer : MTLBuffer = param.inputVariance.buffer -// -// var invStd: [Float32] = Array(repeating: 0, count: varianceBuffer.length) -// let varianceContents = varianceBuffer.contents().assumingMemoryBound(to: P.self) -// for i in 0..<(varianceBuffer.length / MemoryLayout

.stride) { -// invStd[i] = 1 / (Float32(varianceContents[i]) + param.epsilon).squareRoot() -// } -// -// let newScaleContents = newScale.contents().assumingMemoryBound(to: P.self) -// let newBiasContents = newBias.contents().assumingMemoryBound(to: P.self) -// let scale : MTLBuffer = param.inputScale.buffer -// let scaleContents = scale.contents().assumingMemoryBound(to: P.self) -// let bias : MTLBuffer = param.inputBias.buffer -// let biasContents = bias.contents().assumingMemoryBound(to: P.self) -// let meanContents = param.inputMean.buffer.contents().assumingMemoryBound(to: P.self) -// -// for i in 0..<(newScale.length / MemoryLayout

.stride) { -// newScaleContents[i] = P(invStd[i] * Float32(scaleContents[i])) -// newBiasContents[i] = P(Float32(biasContents[i]) - Float32(meanContents[i]) * invStd[i] * Float32(scaleContents[i])) -// } } func compute(commandBuffer: MTLCommandBuffer, param: BatchNormParam

) throws { guard let encoder = commandBuffer.makeComputeCommandEncoder() else { throw PaddleMobileError.predictError(message: " encoder is nil") } -// encoder.setTexture(param.input.metalTexture, index: 0) -// encoder.setTexture(param.output.metalTexture, index: 1) -// encoder.setBuffer(newScale, offset: 0, index: 0) -// encoder.setBuffer(newBias, offset: 0, index: 1) + encoder.setTexture(param.input.metalTexture, index: 0) + encoder.setTexture(param.output.metalTexture, index: 1) + encoder.setBuffer(param.scale.buffer, offset: 0, index: 0) + encoder.setBuffer(param.bias.buffer, offset: 0, index: 1) encoder.dispatch(computePipline: pipline, outTexture: param.output.metalTexture) encoder.endEncoding() } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BilinearInterpKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BilinearInterpKernel.swift index ab6a44187f75fdee9484026ec859347b6c6166dc..7f3e7433760cc1fa4d093b08027bce7c79172532 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BilinearInterpKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BilinearInterpKernel.swift @@ -27,10 +27,16 @@ class BilinearInterpKernel: Kernel, Computable{ encoder.setTexture(param.input.metalTexture, index: 0) encoder.setTexture(param.output.metalTexture, index: 1) - let ratio_h: Float32 = Float32(param.input.tensorDim.dims[2]) / Float32(param.output.tensorDim.dims[2]) - let ratio_w: Float32 = Float32(param.input.tensorDim.dims[3]) / Float32(param.output.tensorDim.dims[3]) + var ratio_h: Float32 = 0 + var ratio_w: Float32 = 0 + if param.output.tensorDim.dims[2] > 1 { + ratio_h = Float32(param.input.tensorDim.dims[2]-1) / Float32(param.output.tensorDim.dims[2]-1) + } + if param.output.tensorDim.dims[3] > 1 { + ratio_w = Float32(param.input.tensorDim.dims[3]-1) / Float32(param.output.tensorDim.dims[3]-1) + } var p = BilinearInterpMetalParam.init(ratio_h: ratio_h, ratio_w: ratio_w) - encoder.setBytes(&p, length: MemoryLayout.size, index: 0) + encoder.setBytes(&p, length: MemoryLayout.size, index: 0) encoder.dispatch(computePipline: pipline, outTexture: param.output.metalTexture) encoder.endEncoding() } @@ -38,7 +44,7 @@ class BilinearInterpKernel: Kernel, Computable{ required init(device: MTLDevice, param: BilinearInterpParam

) { param.output.initTexture(device: device, inTranspose: param.input.transpose, computePrecision: computePrecision) if computePrecision == .Float32 { - super.init(device: device, inFunctionName: "bilinear_interp") + super.init(device: device, inFunctionName: "bilinear_interp_float") } else if computePrecision == .Float16 { super.init(device: device, inFunctionName: "bilinear_interp_half") } else { diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BoxcoderKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BoxcoderKernel.swift index 939f5db5f192082470ea2ad8773db95af22ffed4..c084d9b28e1dc7019a14d3ae317ddf8a64547830 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BoxcoderKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BoxcoderKernel.swift @@ -33,9 +33,9 @@ class BoxcoderKernel: Kernel, Computable{ } required init(device: MTLDevice, param: BoxcoderParam

) { - param.output.initTexture(device: device, computePrecision: computePrecision) + param.output.initTexture(device: device, inTranspose: [0, 3, 1, 2], computePrecision: computePrecision) if computePrecision == .Float32 { - super.init(device: device, inFunctionName: "boxcoder") + super.init(device: device, inFunctionName: "boxcoder_float") } else if computePrecision == .Float16 { super.init(device: device, inFunctionName: "boxcoder_half") } else { diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConcatKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConcatKernel.swift index 644476ad9dbb471786611fe25a30ed9c4833edbd..81ef46c0b3e919615d07f667851007e95b02d54f 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConcatKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConcatKernel.swift @@ -31,101 +31,111 @@ struct ConcatMetalParam { } class ConcatKernel: Kernel, Computable{ - - func encodeTest(_ cmdBuffer: MTLCommandBuffer, _ param: ConcatTestParam, _ istart: Int, _ iend: Int) { - let encoder = cmdBuffer.makeComputeCommandEncoder()! - var p = ConcatMetalParam.init() - var odim: [Int32] = [1, 1, 1, 1] - for i in 0..) throws { + + guard let encoder = commandBuffer.makeComputeCommandEncoder() else { + throw PaddleMobileError.predictError(message: " encode is nil") } - var vdim: [Int32] = [] - for i in 0..<(iend - istart) { - encoder.setTexture(param.input[i+istart], index: i) - vdim.append(Int32(param.dims[i+istart][Int(param.axis)])) + let num = param.input.count + for i in 0...size, index: 0) - encoder.dispatch(computePipline: pipline, outTexture: param.output) + encoder.setBytes(&pm, length: MemoryLayout.size, index: 0) + encoder.dispatch(computePipline: pipline, outTexture: param.output.metalTexture) encoder.endEncoding() } - - func encode(_ cmdBuffer: MTLCommandBuffer, _ param: ConcatParam

, _ istart: Int, _ iend: Int) throws { - guard let encoder = cmdBuffer.makeComputeCommandEncoder() else { - throw PaddleMobileError.predictError(message: " encode is nil") - } - var p = ConcatMetalParam.init() - let odim = (0..<4).map { Int32(param.output.dim[$0]) } - p.odim = (odim[0], odim[1], odim[2], odim[3]) - p.axis = Int32(4 - param.output.tensorDim.cout() + param.axis) + + required init(device: MTLDevice, param: ConcatParam

) { + param.output.initTexture(device: device, inTranspose: param.transpose, computePrecision: computePrecision) + let orank = param.output.tensorDim.cout() + let num = param.input.count + assert(num <= 6) + var axis = 4 - param.output.tensorDim.cout() + param.axis for i in 0..<4 { - if Int32(param.transpose[i]) == p.axis { - p.axis = Int32(i) + if param.transpose[i] == axis { + axis = i break } } - for i in 0...size, index: 0) - encoder.dispatch(computePipline: pipline, outTexture: param.output.metalTexture) - encoder.endEncoding() - } - - func compute(commandBuffer: MTLCommandBuffer, param: ConcatParam

) throws { - - let group = param.input.count / 6 - let remain = param.input.count % 6 - for i in 0.. 0 { - try self.encode(commandBuffer, param, 6 * group, param.input.count) - } - } - - func test(cmdBuffer: MTLCommandBuffer, param: ConcatTestParam) { - let group = param.input.count / 6 - let remain = param.input.count % 6 - for i in 0.. 0 { - self.encodeTest(cmdBuffer, param, 6 * group, param.input.count) + if orank == 4 { + if axis == 1 { + v = "y" + } else if axis == 2 { + v = "x" + } else { + if (param.output.dim[0] == 1) && axis == 3 { + var vz = true + for i in 0..) { - param.output.initTexture(device: device, inTranspose: param.transpose, computePrecision: computePrecision) + pm.vdim = (Int32(vdim[0]), Int32(vdim[1]), Int32(vdim[2]), Int32(vdim[3]), Int32(vdim[4]), Int32(vdim[5])) if computePrecision == .Float32 { - super.init(device: device, inFunctionName: "concat") + super.init(device: device, inFunctionName: "concat_\(orank)_\(num)_\(v)_float") } else if computePrecision == .Float16 { - super.init(device: device, inFunctionName: "concat_half") + super.init(device: device, inFunctionName: "concat_\(orank)_\(num)_\(v)_half") } else { fatalError() } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddPreluKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddPreluKernel.swift new file mode 100644 index 0000000000000000000000000000000000000000..44369f22a9300bd0e5e6ac7c41b2f127bc5b5ff8 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddPreluKernel.swift @@ -0,0 +1,150 @@ +/* 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 ConvAddPreluKernel: Kernel, Computable { + var metalParam: MetalConvParam! + required init(device: MTLDevice, param: ConvAddPreluParam

) { + param.output.initTexture(device: device, inTranspose: [0, 2, 3, 1], computePrecision: computePrecision) + param.filter.initBuffer(device: device, precision: computePrecision) + param.y.initBuffer(device: device, precision: computePrecision) + param.alpha.initBuffer(device: device, precision: computePrecision) + + if computePrecision == .Float16 { + if param.filter.width == 1 && param.filter.height == 1 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "conv_add_1x1_prelu_channel_half") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "conv_add_1x1_prelu_element_half") + } else { + super.init(device: device, inFunctionName: "conv_add_1x1_prelu_other_half") + } + + } else if param.filter.channel == 1 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "depthwise_conv_add_3x3_prelu_channel_half") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "depthwise_conv_add_3x3_prelu_element_half") + } else { + super.init(device: device, inFunctionName: "depthwise_conv_add_3x3_prelu_other_half") + } + } else if param.filter.width == 3 && param.filter.height == 3 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "conv_add_3x3_prelu_channel_half") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "conv_add_3x3_prelu_element_half") + } else { + super.init(device: device, inFunctionName: "conv_add_3x3_prelu_other_half") + } + + } else if param.filter.width == 1 && param.filter.height == 5 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "conv_add_5x1_prelu_channel_half") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "conv_add_5x1_prelu_element_half") + } else { + super.init(device: device, inFunctionName: "conv_add_5x1_prelu_other_half") + } + } else if param.filter.width == 5 && param.filter.height == 1 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "conv_add_1x5_prelu_channel_half") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "conv_add_1x5_prelu_element_half") + } else { + super.init(device: device, inFunctionName: "conv_add_1x5_prelu_other_half") + } + } else { + fatalError(" unsupport yet ") + } + } else if computePrecision == .Float32 { + if param.filter.width == 1 && param.filter.height == 1 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "conv_add_1x1_prelu_channel_float") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "conv_add_1x1_prelu_element_float") + } else { + super.init(device: device, inFunctionName: "conv_add_1x1_prelu_other_float") + } + } else if param.filter.channel == 1 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "depthwise_conv_add_3x3_prelu_channel_float") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "depthwise_conv_add_3x3_prelu_element_float") + } else { + super.init(device: device, inFunctionName: "depthwise_conv_add_3x3_prelu_other_float") + } + } else if param.filter.width == 3 && param.filter.height == 3 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "conv_add_3x3_prelu_channel_float") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "conv_add_3x3_prelu_element_float") + } else { + super.init(device: device, inFunctionName: "conv_add_3x3_prelu_other_float") + } + + } else if param.filter.width == 1 && param.filter.height == 5 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "conv_add_5x1_prelu_channel_float") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "conv_add_5x1_prelu_element_float") + } else { + super.init(device: device, inFunctionName: "conv_add_5x1_prelu_other_float") + } + } else if param.filter.width == 5 && param.filter.height == 1 { + if param.mode == "channel" { + super.init(device: device, inFunctionName: "conv_add_1x5_prelu_channel_float") + } else if param.mode == "element" { + super.init(device: device, inFunctionName: "conv_add_1x5_prelu_element_float") + } else { + super.init(device: device, inFunctionName: "conv_add_1x5_prelu_other_float") + } + } else { + fatalError(" unsupport yet ") + } + } else { + fatalError() + } + + let offsetY = (Int(param.dilations[1]) * (param.filter.height - 1) + 1)/2 - Int(param.paddings[1]) + + let offsetX = (Int(param.dilations[0]) * (param.filter.width - 1) + 1)/2 - Int(param.paddings[0]) + + // print(" function: \(functionName)") + // print("offset x: \(offsetX)") + // print("offset y: \(offsetY)") + + let offsetZ = 0.0 + let inMetalParam = MetalConvParam.init(offsetX: Int16(offsetX), offsetY: Int16(offsetY), offsetZ: Int16(offsetZ), strideX: UInt16(param.stride[0]), strideY: UInt16(param.stride[1]), dilationX: UInt16(param.dilations[0]), dilationY: UInt16(param.dilations[1])) + // print("metal param: ") + // print(inMetalParam) + + metalParam = inMetalParam + } + + func compute(commandBuffer: MTLCommandBuffer, param: ConvAddPreluParam

) throws { +// guard let encoder = commandBuffer.makeComputeCommandEncoder() else { +// throw PaddleMobileError.predictError(message: " encode is nil") +// } +// +// encoder.setTexture(param.input.metalTexture, index: 0) +// encoder.setTexture(param.output.metalTexture, index: 1) +// encoder.setBytes(&metalParam, length: MemoryLayout.size, index: 0) +// encoder.setBuffer(param.filter.buffer, offset: 0, index: 1) +// encoder.setBuffer(param.y.buffer, offset: 0, index: 2) +// encoder.setBuffer(param.alpha.buffer, offset: 0, index: 3) +// encoder.dispatch(computePipline: pipline, outTexture: param.output.metalTexture) +// encoder.endEncoding() + } +} diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/FlattenKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/FlattenKernel.swift new file mode 100644 index 0000000000000000000000000000000000000000..090c55b16160dca19bfcdc4f3467cacdbc9a20c2 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/FlattenKernel.swift @@ -0,0 +1,71 @@ +/* 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 FlattenMetalParam { + var idim: (Int32, Int32, Int32, Int32) + var itrans: (Int32, Int32, Int32, Int32) + var odim: (Int32, Int32, Int32, Int32) + var otrans: (Int32, Int32, Int32, Int32) +} + + +class FlattenKernel: Kernel, Computable{ + + var metalParam: FlattenMetalParam + + required init(device: MTLDevice, param: FlattenParam

) { + param.output.initTexture(device: device, computePrecision: computePrecision) + var id: [Int32] = [1, 1, 1, 1] + for i in 0..) throws { + guard let encoder = commandBuffer.makeComputeCommandEncoder() else { + throw PaddleMobileError.predictError(message: " encoder is nil") + } + + encoder.setTexture(param.input.metalTexture, index: 0) + encoder.setTexture(param.output.metalTexture, index: 1) + + encoder.setBytes(&metalParam, length: MemoryLayout.size, index: 0) + encoder.dispatch(computePipline: pipline, outTexture: param.output.metalTexture) + encoder.endEncoding() + } +} diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/MulticlassNMSKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/MulticlassNMSKernel.swift index 5ee4a5b31c5ee22cf28bf54fd8f7df13d14f9610..3f78efb89e47197ae0af6a1bb53955bc4a937eda 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/MulticlassNMSKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/MulticlassNMSKernel.swift @@ -15,11 +15,41 @@ import Foundation class MulticlassNMSKernel: Kernel, Computable{ - + let pipline1: MTLComputePipelineState + required init(device: MTLDevice, param: MulticlassNMSParam

) { - super.init(device: device, inFunctionName: "place_holder") + + param.middleOutput.initBuffer(device: device) + param.bboxOutput.initBuffer(device: device) + if computePrecision == .Float32 { + pipline1 = device.pipeLine(funcName: "nms_fetch_bbox", inPaddleMobileLib: true) + super.init(device: device, inFunctionName: "nms_fetch_result") + } else if computePrecision == .Float16 { + pipline1 = device.pipeLine(funcName: "nms_fetch_bbox_half", inPaddleMobileLib: true) + super.init(device: device, inFunctionName: "nms_fetch_result_half") + } else { + fatalError( " unsupport precision " ) + } + } func compute(commandBuffer: MTLCommandBuffer, param: MulticlassNMSParam

) throws { + guard let encoder = commandBuffer.makeComputeCommandEncoder() else { + throw PaddleMobileError.predictError(message: " encode is nil") + } + + encoder.setTexture(param.scores.metalTexture, index: 0) + encoder.setBuffer(param.middleOutput.resultBuffer!, offset: 0, index: 0) + encoder.dispatch(computePipline: pipline, outTexture: param.scores.metalTexture) + encoder.endEncoding() + + guard let encoderBox = commandBuffer.makeComputeCommandEncoder() else { + throw PaddleMobileError.predictError(message: " encode is nil") + } + + encoderBox.setTexture(param.bboxes.metalTexture, index: 0) + encoderBox.setBuffer(param.bboxOutput.resultBuffer!, offset: 0, index: 0) + encoderBox.dispatch(computePipline: pipline1, outTexture: param.bboxes.metalTexture) + encoderBox.endEncoding() } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/PriorBoxKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/PriorBoxKernel.swift index 426e91cfbe26385a7b30931d155513633d2bc988..be18c4411ffbef704dff61bb2aa82bc338daf163 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/PriorBoxKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/PriorBoxKernel.swift @@ -34,24 +34,44 @@ class PriorBoxKernel: Kernel, Computable{ required init(device: MTLDevice, param: PriorBoxParam

) { - param.output.initTexture(device: device, inTranspose: [2, 0, 1, 3], computePrecision: computePrecision) + let originDim = param.output.tensorDim; + + param.output.tensorDim = Dim.init(inDim: [1, originDim[0], originDim[1], originDim[2] * originDim[3]]) + param.output.padToFourDim = Dim.init(inDim: [1, originDim[0], originDim[1], originDim[2] * originDim[3]]) + + param.output.initTexture(device: device, inTranspose: [0, 1, 2, 3], computePrecision: computePrecision) param.outputVariances.initTexture(device: device, inTranspose: [2, 0, 1, 3], computePrecision: computePrecision) + if computePrecision == .Float32 { - super.init(device: device, inFunctionName: "prior_box") + if param.min_max_aspect_ratios_order { + super.init(device: device, inFunctionName: "prior_box_MinMaxAspectRatiosOrder") + } else { + super.init(device: device, inFunctionName: "prior_box") + } + } else if computePrecision == .Float16 { - super.init(device: device, inFunctionName: "prior_box_half") + if param.min_max_aspect_ratios_order { + super.init(device: device, inFunctionName: "prior_box_MinMaxAspectRatiosOrder_half") + } else { + super.init(device: device, inFunctionName: "prior_box_half") + } } else { fatalError() } - let n = 1 - let h = param.output.dim[1] - let w = param.output.dim[2] - let c = param.output.dim[3] * param.output.dim[0] - param.output.dim = Dim.init(inDim: [n, h, w, c]) - param.output.transpose = [0, 1, 2, 3] + guard param.minSizes.count == 1 else { + fatalError(" need implement ") + } + +// let n = 1 +// let h = param.output.dim[1] +// let w = param.output.dim[2] +// let c = param.output.dim[3] * param.output.dim[0] +// +// param.output.dim = Dim.init(inDim: [n, h, w, c]) +// param.output.transpose = [0, 1, 2, 3] let imageWidth = Float32(param.inputImage.padToFourDim[3]) let imageHeight = Float32(param.inputImage.padToFourDim[2]) diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ReshapeKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ReshapeKernel.swift index 91708ff7081e805ddb12777114ff32743c629207..4114d3c3c62054235cd57fe37fe9cd83c5bb58cb 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ReshapeKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ReshapeKernel.swift @@ -49,10 +49,12 @@ class ReshapeKernel: Kernel, Computable{ odim: (od[0], od[1], od[2], od[3]), otrans: (ot[0], ot[1], ot[2], ot[3]) ) + let irank = param.input.tensorDim.cout() + let orank = param.output.tensorDim.cout() if computePrecision == .Float32 { - super.init(device: device, inFunctionName: "reshape") + super.init(device: device, inFunctionName: "reshape_\(irank)_\(orank)_float") } else if computePrecision == .Float16 { - super.init(device: device, inFunctionName: "reshape_half") + super.init(device: device, inFunctionName: "reshape_\(irank)_\(orank)_half") } else { fatalError() } @@ -72,7 +74,7 @@ class ReshapeKernel: Kernel, Computable{ guard let encoder = commandBuffer.makeComputeCommandEncoder() else { throw PaddleMobileError.predictError(message: " encoder is nil") } - + encoder.setTexture(param.input.metalTexture, index: 0) encoder.setTexture(param.output.metalTexture, index: 1) @@ -81,15 +83,15 @@ class ReshapeKernel: Kernel, Computable{ encoder.endEncoding() } - func test(commandBuffer: MTLCommandBuffer, testParam: ReshapeTestParam) { - guard let encoder = commandBuffer.makeComputeCommandEncoder() else { - fatalError() - } - encoder.setTexture(testParam.inputTexture, index: 0) - encoder.setTexture(testParam.outputTexture, index: 1) - var pm: ReshapeMetalParam = testParam.param - encoder.setBytes(&pm, length: MemoryLayout.size, index: 0) - encoder.dispatch(computePipline: pipline, outTexture: testParam.outputTexture) - encoder.endEncoding() - } +// func test(commandBuffer: MTLCommandBuffer, testParam: ReshapeTestParam) { +// guard let encoder = commandBuffer.makeComputeCommandEncoder() else { +// fatalError() +// } +// encoder.setTexture(testParam.inputTexture, index: 0) +// encoder.setTexture(testParam.outputTexture, index: 1) +// var pm: ReshapeMetalParam = testParam.param +// encoder.setBytes(&pm, length: MemoryLayout.size, index: 0) +// encoder.dispatch(computePipline: pipline, outTexture: testParam.outputTexture) +// encoder.endEncoding() +// } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ShapeKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ShapeKernel.swift index 2efcd45da4b717dbabdb918d95df64d2bc9b174b..feb052a44fdc7c6134cc90f07f3fc94ad0a497df 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ShapeKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ShapeKernel.swift @@ -19,19 +19,20 @@ struct ShapeMetalParam { class ShapeKernel: Kernel, Computable{ func compute(commandBuffer: MTLCommandBuffer, param: ShapeParam

) throws { - guard let encoder = commandBuffer.makeComputeCommandEncoder() else { - throw PaddleMobileError.predictError(message: " encode is nil") - } - encoder.setTexture(param.output.metalTexture, index: 0) - encoder.endEncoding() +// print("shape compute") +// guard let encoder = commandBuffer.makeComputeCommandEncoder() else { +// throw PaddleMobileError.predictError(message: " encode is nil") +// } +// encoder.setTexture(param.output.metalTexture, index: 0) +// encoder.endEncoding() } required init(device: MTLDevice, param: ShapeParam

) { param.output.initTexture(device: device, computePrecision: computePrecision) if computePrecision == .Float32 { - super.init(device: device, inFunctionName: "split") + super.init(device: device, inFunctionName: "shape") } else if computePrecision == .Float16 { - super.init(device: device, inFunctionName: "split_half") + super.init(device: device, inFunctionName: "shape_half") } else { fatalError() } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SoftmaxKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SoftmaxKernel.swift index e0bcaeaa73f15cc4f43186c01c0394da6e447946..5d6874da151b64fd58c2016865515778d6267551 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SoftmaxKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SoftmaxKernel.swift @@ -29,7 +29,7 @@ class SoftmaxKernel: Kernel, Computable{ K: Int32(param.input.tensorDim[1]) ) if computePrecision == .Float32 { - super.init(device: device, inFunctionName: "softmax") + super.init(device: device, inFunctionName: "softmax_float") } else if computePrecision == .Float16 { super.init(device: device, inFunctionName: "softmax_half") } else { diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SplitKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SplitKernel.swift index a25a70064045a17bb46a22fbbddf824f1d99e51c..67e1cd9ab85c3c60d89846bab89ef10bbe513305 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SplitKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SplitKernel.swift @@ -15,23 +15,76 @@ import Foundation struct SplitMetalParam { + var idim: (Int32, Int32, Int32, Int32) = (1, 1, 1, 1) + var axis: Int32 = 0 + var offset: Int32 = 0 + var trans: (Int32, Int32, Int32, Int32) = (0, 1, 2, 3) + var vdim: (Int32, Int32, Int32, Int32) = (0, 0, 0, 0) } class SplitKernel: Kernel, Computable{ + var smp: SplitMetalParam func compute(commandBuffer: MTLCommandBuffer, param: SplitParam

) throws { guard let encoder = commandBuffer.makeComputeCommandEncoder() else { throw PaddleMobileError.predictError(message: " encode is nil") } - encoder.setTexture(param.output.metalTexture, index: 0) + encoder.setTexture(param.input.metalTexture, index: 0) + for i in 0...size, index: 0) + encoder.dispatch(computePipline: pipline, outTexture: param.input.metalTexture) encoder.endEncoding() } required init(device: MTLDevice, param: SplitParam

) { - param.output.initTexture(device: device, computePrecision: computePrecision) + // param.output.initTexture(device: device, computePrecision: computePrecision) + let num = param.outputList.count + let rank = param.input.tensorDim.cout() + assert(num >= 2 && num <= 4) + for output in param.outputList { + output.initTexture(device: device, inTranspose: param.input.transpose, computePrecision: computePrecision) + } + smp = SplitMetalParam.init() + smp.idim = (Int32(param.input.dim[0]), Int32(param.input.dim[1]), Int32(param.input.dim[2]), Int32(param.input.dim[3])) + smp.axis = Int32(param.axis + param.input.dim.cout() - param.input.tensorDim.cout()) + for i in 0..<4 { + if param.input.transpose[i] == smp.axis { + smp.axis = Int32(i) + break + } + } + smp.trans = (Int32(param.input.transpose[0]), Int32(param.input.transpose[1]), Int32(param.input.transpose[2]), Int32(param.input.transpose[3])) + var vdim: [Int32] = [0, 0, 0, 0] + for i in 0..: Kernel, Computable, Testable { - +class TransposeKernel: Kernel, Computable { + var metalParam: TransposeMetalParam = TransposeMetalParam.init() required init(device: MTLDevice, param: TransposeParam

) { - param.output.initTexture(device: device, inTranspose: [0, 1, 2, 3], computePrecision: computePrecision) - - if computePrecision == .Float16 { - super.init(device: device, inFunctionName: "transpose_half") - } else if computePrecision == .Float32 { - super.init(device: device, inFunctionName: "transpose") - } else { - fatalError() - } - var invT: [Int] = [0, 1, 2, 3] - for (i, v) in param.input.transpose.enumerated() { - invT[v] = i - } + param.output.initTexture(device: device, computePrecision: computePrecision) + let rank = param.input.tensorDim.cout() var axis: [Int] = [0, 1, 2, 3] - for i in 0.. transpose! FAST :)") - } else { -// print("====> transpose! SLOW :(") + + var naxis: [Int] = [0, 0, 0, 0] + for i in 0..<4 { + for j in 0..<4 { + if param.input.transpose[j] == axis[i] { + naxis[i] = j + break + } + } } - metalParam = tmp - } - - required init(device: MTLDevice, testParam: TransposeTestParam) { + metalParam.iC = Int32(param.input.dim[param.input.transpose[3]]) + metalParam.oC = Int32(param.output.dim[3]) + metalParam.axis = (Int32(naxis[0]), Int32(naxis[1]), Int32(naxis[2]), Int32(naxis[3])) + var kernelFunc = "transpose_undefined" if computePrecision == .Float16 { - super.init(device: device, inFunctionName: "transpose_half") + if param.input.transpose == axis { + kernelFunc = "transpose_copy_half" + } else { + kernelFunc = "transpose_\(rank)_half" + } } else if computePrecision == .Float32 { - super.init(device: device, inFunctionName: "transpose") + if param.input.transpose == axis { + kernelFunc = "transpose_copy_float" + } else { + kernelFunc = "transpose_\(rank)_float" + } } else { fatalError() } + print("===========>", kernelFunc) + print(metalParam) + super.init(device: device, inFunctionName: kernelFunc) } - var metalParam: TransposeMetalParam! func compute(commandBuffer: MTLCommandBuffer, param: TransposeParam

) throws { guard let encoder = commandBuffer.makeComputeCommandEncoder() else { throw PaddleMobileError.predictError(message: " encode is nil") @@ -95,20 +74,6 @@ class TransposeKernel: Kernel, Computable, Testable { encoder.dispatch(computePipline: pipline, outTexture: param.output.metalTexture) encoder.endEncoding() } - - public func test(commandBuffer: MTLCommandBuffer, param: TransposeTestParam) { - guard let encoder = commandBuffer.makeComputeCommandEncoder() else { - fatalError() - } - - encoder.setTexture(param.inputTexture, index: 0) - encoder.setTexture(param.outputTexture, index: 1) - var tmp = TransposeMetalParam.init(param.axis) - tmp.iC = Int32(param.iC) - tmp.oC = Int32(param.oC) - - encoder.setBytes(&tmp, length: MemoryLayout.size, index: 0) - encoder.dispatch(computePipline: pipline, outTexture: param.outputTexture) - encoder.endEncoding() - }} + +} diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BatchNormKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BatchNormKernel.metal index 2311836eef03ebf13e1793d812f9f28a37a8402b..96333a07a9669ecb2b5bfe901d71be729e37b533 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BatchNormKernel.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BatchNormKernel.metal @@ -15,28 +15,28 @@ #include using namespace metal; -kernel void batchnorm_half(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - const device half4 * newScale [[buffer(0)]], - const device half4 * newBias [[buffer(1)]], +kernel void batchnorm(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + const device float4 * nscale [[buffer(0)]], + const device float4 * nbias [[buffer(1)]], uint3 gid [[thread_position_in_grid]]) { if (gid.x >= outTexture.get_width() || gid.y >= outTexture.get_height() || gid.z >= outTexture.get_array_size()) return; - const half4 input = inTexture.read(gid.xy, gid.z); - half4 output = input * newScale[gid.z] + newBias[gid.z]; + const float4 input = inTexture.read(gid.xy, gid.z); + float4 output = input * nscale[gid.z] + nbias[gid.z]; outTexture.write(output, gid.xy, gid.z); } -kernel void batchnorm(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - const device float4 * newScale [[buffer(0)]], - const device float4 * newBias [[buffer(1)]], - uint3 gid [[thread_position_in_grid]]) { +kernel void batchnorm_half(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + const device half4 * newScale [[buffer(0)]], + const device half4 * newBias [[buffer(1)]], + uint3 gid [[thread_position_in_grid]]) { if (gid.x >= outTexture.get_width() || gid.y >= outTexture.get_height() || gid.z >= outTexture.get_array_size()) return; - const float4 input = inTexture.read(gid.xy, gid.z); - float4 output = input * newScale[gid.z] + newBias[gid.z]; + const half4 input = inTexture.read(gid.xy, gid.z); + half4 output = input * newScale[gid.z] + newBias[gid.z]; outTexture.write(output, gid.xy, gid.z); } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BilinearInterp.inc.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BilinearInterp.inc.metal new file mode 100644 index 0000000000000000000000000000000000000000..0dc877540876351ebcc5381bb151d2406772cba0 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BilinearInterp.inc.metal @@ -0,0 +1,35 @@ +#ifdef P + +#define CONCAT2(a, b) a ## b +#define CONCAT2_(a, b) a ## _ ## b + +#define FUNC(f, p) CONCAT2_(f, p) +#define VECTOR(p, n) CONCAT2(p, n) + +kernel void FUNC(bilinear_interp, P)(texture2d_array input [[texture(0)]], + texture2d_array output [[texture(1)]], + constant bilinear_interp_param & pm [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + VECTOR(P, 4) r; + if ((input.get_width() == output.get_width()) && (input.get_height() == output.get_height())) { + r = input.read(gid.xy, gid.z); + } else { + P w = gid.x * pm.ratio_w; + P h = gid.y * pm.ratio_h; + uint w0 = w, h0 = h; + uint w1 = w0 + 1, h1 = h0 + 1; + P w1lambda = w - w0, h1lambda = h - h0; + P w2lambda = 1.0 - w1lambda, h2lambda = 1.0 - h1lambda; + if (w1 >= input.get_width()) w1 = w0; + if (h1 >= input.get_height()) h1 = h0; + VECTOR(P, 4) r0 = input.read(uint2(w0, h0), gid.z); + VECTOR(P, 4) r1 = input.read(uint2(w1, h0), gid.z); + VECTOR(P, 4) r2 = input.read(uint2(w0, h1), gid.z); + VECTOR(P, 4) r3 = input.read(uint2(w1, h1), gid.z); + r = h2lambda * (w2lambda * r0 + w1lambda * r1) + + h1lambda * (w2lambda * r2 + w1lambda * r3); + } + output.write(r, gid.xy, gid.z); +} + +#endif diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BilinearInterp.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BilinearInterp.metal index 14b3882e0d18e9bced31263e1f178fd8b9b971f2..394cf89db09d47b0d3c87ff124c21a93962c0972 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BilinearInterp.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BilinearInterp.metal @@ -16,60 +16,14 @@ using namespace metal; struct bilinear_interp_param { -// int32_t out_h; -// int32_t out_w; float ratio_h; float ratio_w; }; -kernel void bilinear_interp(texture2d_array input [[texture(0)]], - texture2d_array output [[texture(2)]], - constant bilinear_interp_param & pm [[buffer(0)]], - uint3 gid [[thread_position_in_grid]]) { - float4 r; - if ((input.get_width() == output.get_width()) && (input.get_height() == output.get_height())) { - r = input.read(gid.xy, gid.z); - } else { - float w = gid.x * pm.ratio_w; - float h = gid.y * pm.ratio_h; - uint w0 = w, h0 = h; - uint w1 = w0 + 1, h1 = h0 + 1; - float w1lambda = w - w0, h1lambda = h - h0; - float w2lambda = 1.0 - w1lambda, h2lambda = 1.0 - h1lambda; - if (w1 >= input.get_width()) w1 = w0; - if (h1 >= input.get_height()) h1 = h0; - float4 r0 = input.read(uint2(w0, h0), gid.z); - float4 r1 = input.read(uint2(w1, h0), gid.z); - float4 r2 = input.read(uint2(w0, h1), gid.z); - float4 r3 = input.read(uint2(w1, h1), gid.z); - r = h2lambda * (w2lambda * r0 + w1lambda * r1) + h1lambda * (w2lambda * r2 + w1lambda * r3); - } - output.write(r, gid.xy, gid.z); -} +#define P float +#include "BilinearInterp.inc.metal" +#undef P -kernel void bilinear_interp_half(texture2d_array input [[texture(0)]], - texture2d_array output [[texture(2)]], - constant bilinear_interp_param & pm [[buffer(0)]], - uint3 gid [[thread_position_in_grid]]) { - - half4 r; - if ((input.get_width() == output.get_width()) && (input.get_height() == output.get_height())) { - r = input.read(gid.xy, gid.z); - } else { - half w = gid.x * pm.ratio_w; - half h = gid.y * pm.ratio_h; - uint w0 = w, h0 = h; - uint w1 = w0 + 1, h1 = h0 + 1; - half w1lambda = w - w0, h1lambda = h - h0; - half w2lambda = 1.0 - w1lambda, h2lambda = 1.0 - h1lambda; - if (w1 >= input.get_width()) w1 = w0; - if (h1 >= input.get_height()) h1 = h0; - half4 r0 = input.read(uint2(w0, h0), gid.z); - half4 r1 = input.read(uint2(w1, h0), gid.z); - half4 r2 = input.read(uint2(w0, h1), gid.z); - half4 r3 = input.read(uint2(w1, h1), gid.z); - r = h2lambda * (w2lambda * r0 + w1lambda * r1) + h1lambda * (w2lambda * r2 + w1lambda * r3); - } - output.write(r, gid.xy, gid.z); - output.write(r, gid.xy, gid.z); -} +#define P half +#include "BilinearInterp.inc.metal" +#undef P diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BoxCoder.inc.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BoxCoder.inc.metal new file mode 100644 index 0000000000000000000000000000000000000000..08c18ab4583a41b3a44ec4a7f63bfe745a92842c --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BoxCoder.inc.metal @@ -0,0 +1,40 @@ +#ifdef P + +#define CONCAT2(a, b) a ## b +#define CONCAT2_(a, b) a ## _ ## b + +#define FUNC(f, p) CONCAT2_(f, p) +#define VECTOR(p, n) CONCAT2(p, n) +kernel void FUNC(boxcoder, P)(texture2d_array priorBox [[texture(0)]], + texture2d_array priorBoxVar [[texture(1)]], + texture2d_array targetBox [[texture(2)]], + texture2d_array output[[texture(3)]], + uint3 gid [[thread_position_in_grid]]) { + VECTOR(P, 4) p = priorBox.read(uint2(0, gid.x), gid.z); + VECTOR(P, 4) pv = priorBoxVar.read(uint2(0, gid.x), gid.z); + VECTOR(P, 4) t; + t[0] = targetBox.read(uint2(0, gid.x), gid.z)[0]; + t[1] = targetBox.read(uint2(1, gid.x), gid.z)[0]; + t[2] = targetBox.read(uint2(2, gid.x), gid.z)[0]; + t[3] = targetBox.read(uint2(3, gid.x), gid.z)[0]; + + P px = (p.x + p.z) / 2; + P py = (p.y + p.w) / 2; + P pw = p.z - p.x; + P ph = p.w - p.y; + + P tx = pv.x * t.x * pw + px; + P ty = pv.y * t.y * ph + py; + P tw = exp(pv.z * t.z) * pw; + P th = exp(pv.w * t.w) * ph; + + VECTOR(P, 4) r; + r.x = tx - tw / 2; + r.y = ty - th / 2; + r.z = tx + tw / 2; + r.w = ty + th / 2; + + output.write(r, gid.xy, gid.z); +} + +#endif diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BoxCoder.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BoxCoder.metal index 7abc17ec6e7a204af4d74b28d40e2a4c69dddc4b..4009e213d51d0a9c33c70aea22b015df49e347dc 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BoxCoder.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/BoxCoder.metal @@ -15,58 +15,9 @@ #include using namespace metal; -kernel void boxcoder(texture2d_array priorBox [[texture(0)]], - texture2d_array priorBoxVar [[texture(1)]], - texture2d_array targetBox [[texture(2)]], - texture2d_array output[[texture(3)]], - uint3 gid [[thread_position_in_grid]]) { - float4 t = targetBox.read(gid.xy, gid.z); - float4 p = priorBox.read(gid.xy, gid.z); - float4 pv = priorBoxVar.read(gid.xy, gid.z); - - float px = (p.x + p.z) / 2; - float py = (p.y + p.w) / 2; - float pw = p.z - p.x; - float ph = p.w - p.y; - - float tx = pv.x * t.x * pw + px; - float ty = pv.y * t.y * ph + py; - float tw = exp(pv.z * t.z) * pw; - float th = exp(pv.w * t.w) * ph; - - float4 r; - r.x = tx - tw / 2; - r.y = ty - th / 2; - r.z = tx + tw / 2; - r.w = ty + th / 2; - - output.write(r, gid.xy, gid.z); -} - -kernel void boxcoder_half(texture2d_array priorBox [[texture(0)]], - texture2d_array priorBoxVar [[texture(1)]], - texture2d_array targetBox [[texture(2)]], - texture2d_array output[[texture(3)]], - uint3 gid [[thread_position_in_grid]]) { - half4 t = targetBox.read(gid.xy, gid.z); - half4 p = priorBox.read(gid.xy, gid.z); - half4 pv = priorBoxVar.read(gid.xy, gid.z); - - float px = (float(p.x) + float(p.z)) / 2; - float py = (float(p.y) + float(p.w)) / 2; - float pw = float(p.z) - float(p.x); - float ph = float(p.w) - float(p.y); - - float tx = float(pv.x) * float(t.x) * pw + px; - float ty = float(pv.y) * float(t.y) * ph + py; - float tw = exp(float(pv.z) * float(t.z)) * pw; - float th = exp(float(pv.w) * float(t.w)) * ph; - - float4 r; - r.x = tx - tw / 2; - r.y = ty - th / 2; - r.z = tx + tw / 2; - r.w = ty + th / 2; - - output.write(half4(r), gid.xy, gid.z); -} +#define P float +#include "BoxCoder.inc.metal" +#undef P +#define P half +#include "BoxCoder.inc.metal" +#undef P diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Common.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Common.metal index da703d163f1f78dbfeb0d33e106c4f8e4ab0c4a2..40bae035c097b5ab386d78520b6b04f074eb2fee 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Common.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Common.metal @@ -15,6 +15,55 @@ #include using namespace metal; + +inline void xyzn2abcd_1(int xyzn[4], int abcd[4]) { + abcd[0] = abcd[1] = abcd[2] = 0; + abcd[3] = xyzn[0] * 4 + xyzn[3]; +} +inline void xyzn2abcd_2(int xyzn[4], int abcd[4]) { + abcd[0] = abcd[1] = 0; + abcd[2] = xyzn[1]; + abcd[3] = xyzn[0] * 4 + xyzn[3]; +} +inline void xyzn2abcd_3(int xyzn[4], int abcd[4]) { + abcd[0] = 0; + abcd[3] = xyzn[0]; + abcd[2] = xyzn[1]; + abcd[1] = xyzn[2] * 4 + xyzn[3]; +} +inline void xyzn2abcd_4(int C, int xyzn[4], int abcd[4]) { + abcd[2] = xyzn[0]; + abcd[1] = xyzn[1]; + uint t = xyzn[2] * 4 + xyzn[3]; + abcd[0] = t / C; + abcd[3] = t % C; +} + +inline void abcd2xyzn_1(int abcd[4], int xyzn[4]) { + xyzn[1] = xyzn[2] = 0; + xyzn[0] = abcd[3] / 4; + xyzn[1] = abcd[3] % 4; +} +inline void abcd2xyzn_2(int abcd[4], int xyzn[4]) { + xyzn[2] = 0; + xyzn[1] = abcd[2]; + xyzn[0] = abcd[3] / 4; + xyzn[3] = abcd[3] % 4; +} +inline void abcd2xyzn_3(int abcd[4], int xyzn[4]) { + xyzn[0] = abcd[3]; + xyzn[1] = abcd[2]; + xyzn[2] = abcd[1] / 4; + xyzn[3] = abcd[1] % 4; +} +inline void abcd2xyzn_4(int C, int abcd[4], int xyzn[4]) { + xyzn[0] = abcd[2]; + xyzn[1] = abcd[1]; + uint t = abcd[0] * C + abcd[3]; + xyzn[2] = t / 4; + xyzn[3] = t % 4; +} + inline void xyzn2abcd(int C, int xyzn[4], int abcd[4]) { abcd[2] = xyzn[0]; abcd[1] = xyzn[1]; diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Concat.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Concat.metal deleted file mode 100644 index 92d80c315e0d5ca19711b4a2165c89077979d49d..0000000000000000000000000000000000000000 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Concat.metal +++ /dev/null @@ -1,116 +0,0 @@ -/* 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. */ - -#include -#include "Common.metal" - -using namespace metal; - -struct ConcatParam { - int32_t odim[4]; - int32_t axis; - int32_t offset; - int32_t trans[4]; - int32_t vdim[6]; -}; - -kernel void concat(texture2d_array in0 [[texture(0)]], - texture2d_array in1 [[texture(1)]], - texture2d_array in2 [[texture(2)]], - texture2d_array in3 [[texture(3)]], - texture2d_array in4 [[texture(4)]], - texture2d_array in5 [[texture(5)]], - texture2d_array inx [[texture(6)]], - texture2d_array out [[texture(7)]], - constant ConcatParam & pm [[buffer(0)]], - uint3 gid [[thread_position_in_grid]]) { - ConcatParam cp = pm; - int xyzn[4] = {int(gid.x), int(gid.y), int(gid.z), 0}, abcd[4], oxyzn[4]; - float4 r; - for (int i = 0; i < 4; i++) { - xyzn[3] = i; - xyzn2abcd(cp.odim[3], xyzn, abcd); - int k = abcd[cp.axis] - cp.offset; - int j = 0; - if (k < 0) { - r[i] = inx.read(gid.xy, gid.z)[i]; - } else { - for (; j < 6; j++) { - if (k < cp.vdim[j]) { - break; - } - k -= cp.vdim[j]; - } - int ta = cp.odim[cp.axis]; - abcd[cp.axis] = k; - cp.odim[cp.axis] = cp.vdim[j]; - abcd2xyzn(cp.odim[3], abcd, oxyzn); - cp.odim[cp.axis] = ta; - switch (j) { - case 0: r[i] = in0.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 1: r[i] = in1.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 2: r[i] = in2.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 3: r[i] = in3.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 4: r[i] = in4.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 5: r[i] = in5.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - } - } - } - out.write(r, gid.xy, gid.z); -} - -kernel void concat_half(texture2d_array in0 [[texture(0)]], - texture2d_array in1 [[texture(1)]], - texture2d_array in2 [[texture(2)]], - texture2d_array in3 [[texture(3)]], - texture2d_array in4 [[texture(4)]], - texture2d_array in5 [[texture(5)]], - texture2d_array inx [[texture(6)]], - texture2d_array out [[texture(7)]], - constant ConcatParam & pm [[buffer(0)]], - uint3 gid [[thread_position_in_grid]]) { - ConcatParam cp = pm; - int xyzn[4] = {int(gid.x), int(gid.y), int(gid.z), 0}, abcd[4], oxyzn[4]; - half4 r; - for (int i = 0; i < 4; i++) { - xyzn[3] = i; - xyzn2abcd(cp.odim[3], xyzn, abcd); - int k = abcd[cp.axis] - cp.offset; - int j = 0; - if (k < 0) { - r[i] = inx.read(gid.xy, gid.z)[i]; - } else { - for (; j < 6; j++) { - if (k < cp.vdim[j]) { - break; - } - k -= cp.vdim[j]; - } - int ta = cp.odim[cp.axis]; - abcd[cp.axis] = k; - cp.odim[cp.axis] = cp.vdim[j]; - abcd2xyzn(cp.odim[3], abcd, oxyzn); - cp.odim[cp.axis] = ta; - switch (j) { - case 0: r[i] = in0.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 1: r[i] = in1.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 2: r[i] = in2.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 3: r[i] = in3.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 4: r[i] = in4.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - case 5: r[i] = in5.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; - } - } - } - out.write(r, gid.xy, gid.z); -} diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.inc.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.inc.metal new file mode 100644 index 0000000000000000000000000000000000000000..b62daaa3aa1dd7861a3b00018bc38b409b05d8e0 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.inc.metal @@ -0,0 +1,304 @@ +#ifdef P + +#define CONCAT2(a, b) a ## b +#define CONCAT2_(a, b) a ## _ ## b +#define CONCAT3_(a, b, c) a ## _ ## b ## _ ## c +#define CONCAT4_(a, b, c, d) a ## _ ## b ## _ ## c ## _ ## d +#define CONCAT5_(a, b, c, d, e) a ## _ ## b ## _ ## c ## _ ## d ## _ ## e + +#define FUNC(f, r, n, v, p) CONCAT5_(f, r, n, v, p) +#define VECTOR(p, n) CONCAT2(p, n) +#define FUNC_R(f, r) CONCAT2_(f, r) + +#if V == VX +#define VV x +#elif V == VY +#define VV y +#elif V == VZ +#define VV z +#else +#define VV normal +#endif + +#if V == VNORMAL +//kernel void FUNC(concat, R, N, normal, P)(array, N> in [[texture(0)]], +// texture2d_array out_x [[texture(N)]], +// texture2d_array out [[texture(N+1)]], +// constant ConcatParam & pm [[buffer(0)]], +// uint3 gid [[thread_position_in_grid]]) { +//} +kernel void FUNC(concat, R, N, VV, P)(texture2d_array in0 [[texture(0)]], + texture2d_array in1 [[texture(1)]], +#if N >= 3 + texture2d_array in2 [[texture(2)]], +#endif +#if N >= 4 + texture2d_array in3 [[texture(3)]], +#endif +#if N >= 5 + texture2d_array in4 [[texture(4)]], +#endif +#if N >= 6 + texture2d_array in5 [[texture(5)]], +#endif + texture2d_array inx [[texture(N)]], + texture2d_array out [[texture(N+1)]], + constant ConcatParam & pm [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + + ConcatParam cp = pm; + int xyzn[4] = {int(gid.x), int(gid.y), int(gid.z), 0}, abcd[4], oxyzn[4]; + VECTOR(P, 4) r = inx.read(gid.xy, gid.z); + for (int i = 0; i < 4; i++) { + xyzn[3] = i; +#if R == 4 + xyzn2abcd_4(cp.odim[3], xyzn, abcd); +#else + FUNC_R(xyzn2abcd, R)(xyzn, abcd); +#endif + int k = abcd[cp.axis] - cp.offset; + if (k < 0) continue; + int j = 0; + for (; j < N; j++) { + if (k < cp.vdim[j]) { + break; + } + k -= cp.vdim[j]; + } + if (k > cp.vdim[N-1]) { + continue; + } + int ta = cp.odim[cp.axis]; + abcd[cp.axis] = k; + cp.odim[cp.axis] = cp.vdim[j]; +#if R == 4 + abcd2xyzn_4(cp.odim[3], abcd, oxyzn); +#else + FUNC_R(abcd2xyzn, R)(abcd, oxyzn); +#endif + cp.odim[cp.axis] = ta; + switch (j) { + case 0: r[i] = in0.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; + case 1: r[i] = in1.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; +#if N >= 3 + case 2: r[i] = in2.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; +#endif +#if N >= 4 + case 3: r[i] = in3.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; +#endif +#if N >= 5 + case 4: r[i] = in4.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; +#endif +#if N >= 6 + case 5: r[i] = in5.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2])[oxyzn[3]]; break; +#endif + } + } + out.write(r, gid.xy, gid.z); +} + +#endif // V == NORMAL + + + +#if V == VX +kernel void FUNC(concat, R, N, VV, P)(texture2d_array in0 [[texture(0)]], + texture2d_array in1 [[texture(1)]], +#if N >= 3 + texture2d_array in2 [[texture(2)]], +#endif // N >= 3 +#if N >= 4 + texture2d_array in3 [[texture(3)]], +#endif // N >= 4 +#if N >= 5 + texture2d_array in4 [[texture(4)]], +#endif // N >= 5 +#if N >= 6 + texture2d_array in5 [[texture(5)]], +#endif // N >= 6 + texture2d_array out [[texture(N)]], + constant ConcatParam & pm [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + int x = gid.x - pm.offset; + if (x < 0) return; + if (x < pm.vdim[0]) { + VECTOR(P, 4) r = in0.read(gid.xy, gid.z); + out.write(r, gid.xy, gid.z); + return; + } + x -= pm.vdim[0]; + if (x < pm.vdim[1]) { + VECTOR(P, 4) r = in1.read(uint2(x, gid.y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#if N >= 3 + x -= pm.vdim[1]; + if (x < pm.vdim[2]) { + VECTOR(P, 4) r = in2.read(uint2(x, gid.y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 3 +#if N >= 4 + x -= pm.vdim[2]; + if (x < pm.vdim[3]) { + VECTOR(P, 4) r = in3.read(uint2(x, gid.y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 4 +#if N >= 5 + x -= pm.vdim[3]; + if (x < pm.vdim[4]) { + VECTOR(P, 4) r = in4.read(uint2(x, gid.y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 5 +#if N >= 6 + x -= pm.vdim[4]; + if (x < pm.vdim[5]) { + VECTOR(P, 4) r = in5.read(uint2(x, gid.y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 6 +} +#endif // V == VX + +#if V == VY +kernel void FUNC(concat, R, N, VV, P)(texture2d_array in0 [[texture(0)]], + texture2d_array in1 [[texture(1)]], +#if N >= 3 + texture2d_array in2 [[texture(2)]], +#endif // N >= 3 +#if N >= 4 + texture2d_array in3 [[texture(3)]], +#endif // N >= 4 +#if N >= 5 + texture2d_array in4 [[texture(4)]], +#endif // N >= 5 +#if N >= 6 + texture2d_array in5 [[texture(5)]], +#endif // N >= 6 + texture2d_array out [[texture(N)]], + constant ConcatParam & pm [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + int y = gid.y - pm.offset; + if (y < 0) return; + if (y < pm.vdim[0]) { + VECTOR(P, 4) r = in0.read(gid.xy, gid.z); + out.write(r, gid.xy, gid.z); + return; + } + y -= pm.vdim[0]; + if (y < pm.vdim[1]) { + VECTOR(P, 4) r = in1.read(uint2(gid.x, y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#if N >= 3 + y -= pm.vdim[1]; + if (y < pm.vdim[2]) { + VECTOR(P, 4) r = in2.read(uint2(gid.x, y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 3 +#if N >= 4 + y -= pm.vdim[2]; + if (y < pm.vdim[3]) { + VECTOR(P, 4) r = in3.read(uint2(gid.x, y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 4 +#if N >= 5 + y -= pm.vdim[3]; + if (y < pm.vdim[4]) { + VECTOR(P, 4) r = in4.read(uint2(gid.x, y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 5 +#if N >= 6 + y -= pm.vdim[4]; + if (y < pm.vdim[5]) { + VECTOR(P, 4) r = in5.read(uint2(gid.x, y), gid.z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 6 +} +#endif // V == VY + +#if V == VZ +kernel void FUNC(concat, R, N, VV, P)(texture2d_array in0 [[texture(0)]], + texture2d_array in1 [[texture(1)]], +#if N >= 3 + texture2d_array in2 [[texture(2)]], +#endif // N >= 3 +#if N >= 4 + texture2d_array in3 [[texture(3)]], +#endif // N >= 4 +#if N >= 5 + texture2d_array in4 [[texture(4)]], +#endif // N >= 5 +#if N >= 6 + texture2d_array in5 [[texture(5)]], +#endif // N >= 6 + texture2d_array out [[texture(N)]], + constant ConcatParam & pm [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + int z = gid.z - pm.offset; + if (z < 0) return; + if (z < pm.vdim[0]) { + VECTOR(P, 4) r = in0.read(gid.xy, gid.z); + out.write(r, gid.xy, gid.z); + return; + } + z -= pm.vdim[0]; + if (z < pm.vdim[1]) { + VECTOR(P, 4) r = in1.read(gid.xy, z); + out.write(r, gid.xy, gid.z); + return; + } +#if N >= 3 + z -= pm.vdim[1]; + if (z < pm.vdim[2]) { + VECTOR(P, 4) r = in2.read(gid.xy, z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 3 +#if N >= 4 + z -= pm.vdim[2]; + if (z < pm.vdim[3]) { + VECTOR(P, 4) r = in3.read(gid.xy, z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 4 +#if N >= 5 + z -= pm.vdim[3]; + if (z < pm.vdim[4]) { + VECTOR(P, 4) r = in4.read(gid.xy, z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 5 +#if N >= 6 + z -= pm.vdim[4]; + if (z < pm.vdim[5]) { + VECTOR(P, 4) r = in5.read(gid.xy, z); + out.write(r, gid.xy, gid.z); + return; + } +#endif // N >= 6 +} +#endif // V == VZ + + +#undef VV +#endif // #ifdef P diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.metal new file mode 100644 index 0000000000000000000000000000000000000000..b7d17f2d25de544e4ce938c577e0d04f536da9af --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.metal @@ -0,0 +1,171 @@ +/* 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. */ + +#include +#include "Common.metal" + +using namespace metal; + +struct ConcatParam { + int32_t odim[4]; + int32_t axis; + int32_t offset; + int32_t trans[4]; + int32_t vdim[6]; +}; + +#define VNORMAL 1 +#define VX 2 +#define VY 3 +#define VZ 4 + +// >> fast mode +// only support concat_{2,3,4}_{2,3,4,5,6}_y_{float,half} +// only support concat_{3,4}_{2,3,4,5,6}_x_{float,half} +// only support concat_{1,2,3,4}_{2,3,4,5,6}_z_{float,half} +// >> normal mode (loop mode) +// ssd-ar: (R=4, N=3, V=z), (R=3, N=2, V=y), (R=2, N=5, V=x), (R=3, N=5, V=x) +// ssd: (R=2, N=6, V=y), (R=3, N=6, V=y) +// genet: (R=4, N=2, V=normal) + +// ssd-ar: (R=3, N=5, V=x) +#define V VX + #define R 3 + #define N 5 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + +// ssd-ar: (R=2, N=5, V=x) +#define V VX + #define R 2 + #define N 5 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + + +// ssd-ar: (R=3, N=2, V=y) +#define V VY + #define R 3 + #define N 2 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + +// ssd-ar: (R=4, N=3, V=z) +#define V VZ + #define R 4 + #define N 3 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + + +// ssd: (R=2, N=6, V=y) +#define V VY + #define R 2 + #define N 6 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + +// ssd: (R=3, N=6, V=y) +#define V VY + #define R 3 + #define N 6 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + +#define V VNORMAL + #define R 4 + #define N 2 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + + +#define V VY + #define R 2 + #define N 2 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + + +#define V VY + #define R 2 + #define N 5 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + + + + diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvAddBNReluKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvAddBNReluKernel.metal index ffa66212b16bb6c6180910cae2d0c34f8659c556..87b60a64fc48ab89af274e0b24897e0b411599e0 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvAddBNReluKernel.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvAddBNReluKernel.metal @@ -17,14 +17,15 @@ using namespace metal; -kernel void conv_add_batch_norm_relu_1x1_half(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - constant MetalConvParam ¶m [[buffer(0)]], - const device half4 *weights [[buffer(1)]], - const device half4 *biase [[buffer(2)]], - const device float4 *new_scale [[buffer(3)]], - const device float4 *new_biase [[buffer(4)]], - uint3 gid [[thread_position_in_grid]]) { +kernel void conv_add_batch_norm_relu_1x1_half( + texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant MetalConvParam ¶m [[buffer(0)]], + const device half4 *weights [[buffer(1)]], + const device half4 *biase [[buffer(2)]], + const device half4 *new_scale [[buffer(3)]], + const device half4 *new_biase [[buffer(4)]], + uint3 gid [[thread_position_in_grid]]) { if (gid.x >= outTexture.get_width() || gid.y >= outTexture.get_height() || @@ -41,7 +42,7 @@ kernel void conv_add_batch_norm_relu_1x1_half(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - constant MetalConvParam ¶m [[buffer(0)]], - const device half4 *weights [[buffer(1)]], - const device half4 *biase [[buffer(2)]], - const device float4 *new_scale [[buffer(3)]], - const device float4 *new_biase [[buffer(4)]], - uint3 gid [[thread_position_in_grid]]) { +kernel void conv_add_batch_norm_relu_3x3_half( + texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant MetalConvParam ¶m [[buffer(0)]], + const device half4 *weights [[buffer(1)]], + const device half4 *biase [[buffer(2)]], + const device half4 *new_scale [[buffer(3)]], + const device half4 *new_biase [[buffer(4)]], + uint3 gid [[thread_position_in_grid]]) { if (gid.x >= outTexture.get_width() || gid.y >= outTexture.get_height() || @@ -86,7 +87,7 @@ kernel void conv_add_batch_norm_relu_3x3_half(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - constant MetalConvParam ¶m [[buffer(0)]], - const device half *weights [[buffer(1)]], - const device half4 *biase [[buffer(2)]], - const device float4 *new_scale [[buffer(3)]], - const device float4 *new_biase [[buffer(4)]], - uint3 gid [[thread_position_in_grid]]) { +kernel void depthwise_conv_add_batch_norm_relu_3x3_half( + texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant MetalConvParam ¶m [[buffer(0)]], + const device half *weights [[buffer(1)]], + const device half4 *biase [[buffer(2)]], + const device half4 *new_scale [[buffer(3)]], + const device half4 *new_biase [[buffer(4)]], + uint3 gid [[thread_position_in_grid]]) { if (gid.x >= outTexture.get_width() || gid.y >= outTexture.get_height() || @@ -138,7 +139,7 @@ kernel void depthwise_conv_add_batch_norm_relu_3x3_half(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant MetalConvParam ¶m [[buffer(0)]], + const device VECTOR(P, 4) *weights [[buffer(1)]], + const device VECTOR(P, 4) *biase [[buffer(2)]], +#ifdef PRELU_CHANNEL + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_ELEMENT + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_OTHER + const device P *alpha [[buffer(3)]], +#endif + uint3 gid [[thread_position_in_grid]]) { + + if (gid.x >= outTexture.get_width() || + gid.y >= outTexture.get_height() || + gid.z >= outTexture.get_array_size()) { + return; + } + + ushort2 stride = ushort2(param.strideX, param.strideY); + ushort2 posInInput = ushort2(gid.xy) * stride + ushort2(param.offsetX, param.offsetY); + + constexpr sampler sample(coord::pixel, filter::nearest, address::clamp_to_zero); + const uint kernelHXW = 1; + + uint input_arr_size = inTexture.get_array_size(); + uint weithTo = gid.z * kernelHXW * input_arr_size * 4; + + float4 output = float4(0.0); + + VECTOR(P, 4) input; + for (uint i = 0; i < input_arr_size; ++i) { + input = inTexture.sample(sample,float2(posInInput.x, posInInput.y), i); + VECTOR(P, 4) weight_x = weights[weithTo + 0 * kernelHXW * input_arr_size + i]; + output.x += dot(input, weight_x); + + VECTOR(P, 4) weight_y = weights[weithTo + 1 * kernelHXW * input_arr_size + i]; + output.y += dot(input, weight_y); + + VECTOR(P, 4) weight_z = weights[weithTo + 2 * kernelHXW * input_arr_size + i]; + output.z += dot(input, weight_z); + + VECTOR(P, 4) weight_w = weights[weithTo + 3 * kernelHXW * input_arr_size + i]; + output.w += dot(input, weight_w); + } + + output = output + float4(biase[gid.z]); + +#ifdef PRELU_CHANNEL + VECTOR(P, 4) alpha_value = alpha[gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_ELEMENT + int alpha_to = (gid.y * outTexture.get_width() + gid.x) * outTexture.get_array_size(); + VECTOR(P, 4) alpha_value = alpha[alpha_to + gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_OTHER + P alpha_value = alpha[0]; + output.x = output.x > 0 ? output.x : (alpha_value * output.x); + output.y = output.y > 0 ? output.y : (alpha_value * output.y); + output.z = output.z > 0 ? output.z : (alpha_value * output.z); + output.w = output.w > 0 ? output.w : (alpha_value * output.w); +#endif + outTexture.write(VECTOR(P, 4)(output), gid.xy, gid.z); +} + +kernel void FUNC3_(conv_add_3x3, PRELU_TYPE, P)(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant MetalConvParam ¶m [[buffer(0)]], + const device VECTOR(P, 4) *weights [[buffer(1)]], + const device VECTOR(P, 4) *biase [[buffer(2)]], +#ifdef PRELU_CHANNEL + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_ELEMENT + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_OTHER + const device P *alpha [[buffer(3)]], +#endif + uint3 gid [[thread_position_in_grid]]) { + if (gid.x >= outTexture.get_width() || + gid.y >= outTexture.get_height() || + gid.z >= outTexture.get_array_size()) { + return; + } + + ushort2 stride = ushort2(param.strideX, param.strideY); + const ushort2 posInInput = ushort2(gid.xy) * stride + ushort2(param.offsetX, param.offsetY); + + constexpr sampler sample(coord::pixel, filter::nearest, address::clamp_to_zero); + + const uint kernelHXW = 9; + + uint input_arr_size = inTexture.get_array_size(); + + uint weithTo = gid.z * kernelHXW * input_arr_size * 4; + + float4 output = float4(0.0); + + ushort dilation_x = param.dilationX; + ushort dilation_y = param.dilationY; + + VECTOR(P, 4) input[9]; + + for (uint i = 0; i < input_arr_size; ++i) { + input[0] = inTexture.sample(sample, float2(posInInput.x - dilation_x, posInInput.y - dilation_y), i); + + input[1] = inTexture.sample(sample, float2(posInInput.x, posInInput.y - dilation_y), i); + + input[2] = inTexture.sample(sample, float2(posInInput.x + dilation_x, posInInput.y - dilation_y), i); + + input[3] = inTexture.sample(sample, float2(posInInput.x - dilation_x, posInInput.y), i); + + input[4] = inTexture.sample(sample, float2(posInInput.x, posInInput.y), i); + + input[5] = inTexture.sample(sample, float2(posInInput.x + dilation_x, posInInput.y), i); + + input[6] = inTexture.sample(sample, float2(posInInput.x - dilation_x, posInInput.y + dilation_y), i); + + input[7] = inTexture.sample(sample, float2(posInInput.x, posInInput.y + dilation_y), i); + + input[8] = inTexture.sample(sample, float2(posInInput.x + dilation_x, posInInput.y + dilation_y), i); + + for (int j = 0; j < 9; ++j) { + VECTOR(P, 4) weight_x = weights[weithTo + 0 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.x += dot(input[j], weight_x); + + VECTOR(P, 4) weight_y = weights[weithTo + 1 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.y += dot(input[j], weight_y); + + VECTOR(P, 4) weight_z = weights[weithTo + 2 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.z += dot(input[j], weight_z); + + VECTOR(P, 4) weight_w = weights[weithTo + 3 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.w += dot(input[j], weight_w); + } + } + output = output + float4(biase[gid.z]); + +#ifdef PRELU_CHANNEL + VECTOR(P, 4) alpha_value = alpha[gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_ELEMENT + int alpha_to = (gid.y * outTexture.get_width() + gid.x) * outTexture.get_array_size(); + VECTOR(P, 4) alpha_value = alpha[alpha_to + gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_OTHER + P alpha_value = alpha[0]; + output.x = output.x > 0 ? output.x : (alpha_value * output.x); + output.y = output.y > 0 ? output.y : (alpha_value * output.y); + output.z = output.z > 0 ? output.z : (alpha_value * output.z); + output.w = output.w > 0 ? output.w : (alpha_value * output.w); +#endif + outTexture.write(VECTOR(P, 4)(output), gid.xy, gid.z); +} + +kernel void FUNC3_(conv_add_5x1, PRELU_TYPE, P)(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant MetalConvParam ¶m [[buffer(0)]], + const device VECTOR(P, 4) *weights [[buffer(1)]], + const device VECTOR(P, 4) *biase [[buffer(2)]], +#ifdef PRELU_CHANNEL + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_ELEMENT + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_OTHER + const device P *alpha [[buffer(3)]], +#endif + uint3 gid [[thread_position_in_grid]]) { + + if (gid.x >= outTexture.get_width() || + gid.y >= outTexture.get_height() || + gid.z >= outTexture.get_array_size()) { + return; + } + + ushort2 stride = ushort2(param.strideX, param.strideY); + const ushort2 posInInput = ushort2(gid.xy) * stride + ushort2(param.offsetX, param.offsetY); + + constexpr sampler sample(coord::pixel, filter::nearest, address::clamp_to_zero); + + const uint kernelHXW = 5; + + uint input_arr_size = inTexture.get_array_size(); + + uint weithTo = gid.z * kernelHXW * input_arr_size * 4; + + float4 output = float4(biase[gid.z]);; + + ushort dilation_y = param.dilationY; + VECTOR(P, 4) input[5]; + + for (uint i = 0; i < input_arr_size; ++i) { + input[0] = inTexture.sample(sample, float2(posInInput.x, posInInput.y - 2 * dilation_y), i); + + input[1] = inTexture.sample(sample, float2(posInInput.x, posInInput.y - dilation_y), i); + + input[2] = inTexture.sample(sample, float2(posInInput.x, posInInput.y), i); + + input[3] = inTexture.sample(sample, float2(posInInput.x, posInInput.y + dilation_y), i); + + input[4] = inTexture.sample(sample, float2(posInInput.x, posInInput.y + 2 * dilation_y), i); + + for (int j = 0; j < 5; ++j) { + VECTOR(P, 4) weight_x = weights[weithTo + 0 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.x += dot(input[j], weight_x); + + VECTOR(P, 4) weight_y = weights[weithTo + 1 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.y += dot(input[j], weight_y); + + VECTOR(P, 4) weight_z = weights[weithTo + 2 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.z += dot(input[j], weight_z); + + VECTOR(P, 4) weight_w = weights[weithTo + 3 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.w += dot(input[j], weight_w); + } + } + +#ifdef PRELU_CHANNEL + VECTOR(P, 4) alpha_value = alpha[gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_ELEMENT + int alpha_to = (gid.y * outTexture.get_width() + gid.x) * outTexture.get_array_size(); + VECTOR(P, 4) alpha_value = alpha[alpha_to + gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_OTHER + P alpha_value = alpha[0]; + output.x = output.x > 0 ? output.x : (alpha_value * output.x); + output.y = output.y > 0 ? output.y : (alpha_value * output.y); + output.z = output.z > 0 ? output.z : (alpha_value * output.z); + output.w = output.w > 0 ? output.w : (alpha_value * output.w); +#endif + outTexture.write(VECTOR(P, 4)(output), gid.xy, gid.z); +} + + +kernel void FUNC3_(conv_add_1x5, PRELU_TYPE, P)(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant MetalConvParam ¶m [[buffer(0)]], + const device VECTOR(P, 4) *weights [[buffer(1)]], + const device VECTOR(P, 4) *biase [[buffer(2)]], +#ifdef PRELU_CHANNEL + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_ELEMENT + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_OTHER + const device P *alpha [[buffer(3)]], +#endif + uint3 gid [[thread_position_in_grid]]) { + + if (gid.x >= outTexture.get_width() || + gid.y >= outTexture.get_height() || + gid.z >= outTexture.get_array_size()) { + return; + } + + ushort2 stride = ushort2(param.strideX, param.strideY); + const ushort2 posInInput = ushort2(gid.xy) * stride + ushort2(param.offsetX, param.offsetY); + + constexpr sampler sample(coord::pixel, filter::nearest, address::clamp_to_zero); + + const uint kernelHXW = 5; + + uint input_arr_size = inTexture.get_array_size(); + + uint weithTo = gid.z * kernelHXW * input_arr_size * 4; + + float4 output = float4(biase[gid.z]); + + ushort dilation_x = param.dilationX; + VECTOR(P, 4) input[5]; + + for (uint i = 0; i < input_arr_size; ++i) { + input[0] = inTexture.sample(sample, float2(posInInput.x - 2 * dilation_x, posInInput.y), i); + + input[1] = inTexture.sample(sample, float2(posInInput.x - dilation_x, posInInput.y), i); + + input[2] = inTexture.sample(sample, float2(posInInput.x, posInInput.y), i); + + input[3] = inTexture.sample(sample, float2(posInInput.x + dilation_x, posInInput.y), i); + + input[4] = inTexture.sample(sample, float2(posInInput.x + 2 * dilation_x, posInInput.y), i); + + for (int j = 0; j < 5; ++j) { + VECTOR(P, 4) weight_x = weights[weithTo + 0 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.x += dot(input[j], weight_x); + + VECTOR(P, 4) weight_y = weights[weithTo + 1 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.y += dot(input[j], weight_y); + + VECTOR(P, 4) weight_z = weights[weithTo + 2 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.z += dot(input[j], weight_z); + + VECTOR(P, 4) weight_w = weights[weithTo + 3 * kernelHXW * input_arr_size + j * input_arr_size + i]; + output.w += dot(input[j], weight_w); + } + } + +#ifdef PRELU_CHANNEL + VECTOR(P, 4) alpha_value = alpha[gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_ELEMENT + int alpha_to = (gid.y * outTexture.get_width() + gid.x) * outTexture.get_array_size(); + VECTOR(P, 4) alpha_value = alpha[alpha_to + gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_OTHER + P alpha_value = alpha[0]; + output.x = output.x > 0 ? output.x : (alpha_value * output.x); + output.y = output.y > 0 ? output.y : (alpha_value * output.y); + output.z = output.z > 0 ? output.z : (alpha_value * output.z); + output.w = output.w > 0 ? output.w : (alpha_value * output.w); +#endif + outTexture.write(VECTOR(P, 4)(output), gid.xy, gid.z); +} + +kernel void FUNC3_(depthwise_conv_add_3x3, PRELU_TYPE, P)(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant MetalConvParam ¶m [[buffer(0)]], + const device P *weights [[buffer(1)]], + const device VECTOR(P, 4) *biase [[buffer(2)]], +#ifdef PRELU_CHANNEL + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_ELEMENT + const device VECTOR(P, 4) *alpha [[buffer(3)]], +#endif +#ifdef PRELU_OTHER + const device P *alpha [[buffer(3)]], +#endif + uint3 gid [[thread_position_in_grid]]) { + + if (gid.x >= outTexture.get_width() || + gid.y >= outTexture.get_height() || + gid.z >= outTexture.get_array_size()) { + return; + } + uint output_slice = gid.z; + ushort2 stride = ushort2(param.strideX, param.strideY); + ushort2 posInInput = ushort2(gid.xy) * stride + ushort2(param.offsetX, param.offsetY); + constexpr sampler sample(coord::pixel, filter::nearest, address::clamp_to_zero); + const uint kernelHXW = 9; + uint weithTo = gid.z * kernelHXW * 4; + float4 output = float4(biase[gid.z]); + VECTOR(P, 4) inputs[9]; + inputs[0] = inTexture.sample(sample, float2(posInInput.x - 1, posInInput.y - 1), output_slice); + inputs[1] = inTexture.sample(sample, float2(posInInput.x, posInInput.y - 1), output_slice); + inputs[2] = inTexture.sample(sample, float2(posInInput.x + 1, posInInput.y - 1), output_slice); + inputs[3] = inTexture.sample(sample, float2(posInInput.x - 1, posInInput.y), output_slice); + inputs[4] = inTexture.sample(sample, float2(posInInput.x, posInInput.y), output_slice); + inputs[5] = inTexture.sample(sample, float2(posInInput.x + 1, posInInput.y), output_slice); + inputs[6] = inTexture.sample(sample, float2(posInInput.x - 1, posInInput.y + 1), output_slice); + inputs[7] = inTexture.sample(sample, float2(posInInput.x, posInInput.y + 1), output_slice); + inputs[8] = inTexture.sample(sample, float2(posInInput.x + 1, posInInput.y + 1), output_slice); + for (int j = 0; j < 9; ++j) { + VECTOR(P, 4) input = inputs[j]; + output.x += input.x * weights[weithTo + 0 * kernelHXW + j]; + output.y += input.y * weights[weithTo + 1 * kernelHXW + j]; + output.z += input.z * weights[weithTo + 2 * kernelHXW + j]; + output.w += input.w * weights[weithTo + 3 * kernelHXW + j]; + } + +#ifdef PRELU_CHANNEL + VECTOR(P, 4) alpha_value = alpha[gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_ELEMENT + int alpha_to = (gid.y * outTexture.get_width() + gid.x) * outTexture.get_array_size(); + VECTOR(P, 4) alpha_value = alpha[alpha_to + gid.z]; + output.x = output.x > 0 ? output.x : (alpha_value.x * output.x); + output.y = output.y > 0 ? output.y : (alpha_value.y * output.y); + output.z = output.z > 0 ? output.z : (alpha_value.z * output.z); + output.w = output.w > 0 ? output.w : (alpha_value.w * output.w); +#endif +#ifdef PRELU_OTHER + P alpha_value = alpha[0]; + output.x = output.x > 0 ? output.x : (alpha_value * output.x); + output.y = output.y > 0 ? output.y : (alpha_value * output.y); + output.z = output.z > 0 ? output.z : (alpha_value * output.z); + output.w = output.w > 0 ? output.w : (alpha_value * output.w); +#endif + outTexture.write(VECTOR(P, 4)(output), gid.xy, gid.z); +} + +#endif + diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvAddPreluKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvAddPreluKernel.metal new file mode 100644 index 0000000000000000000000000000000000000000..f03a1d5b625cf01f1f1bc5ac23bebf7dabd968d9 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvAddPreluKernel.metal @@ -0,0 +1,65 @@ +/* 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. */ + +#include +#include "Common.metal" +using namespace metal; + +#define P float + + #define PRELU_CHANNEL prelu_channel + #define PRELU_TYPE prelu_channel + #include "ConvAddPrelu.inc.metal" + #undef PRELU_TYPE + #undef PRELU_CHANNEL + + #define PRELU_ELEMENT prelu_element + #define PRELU_TYPE prelu_element + #include "ConvAddPrelu.inc.metal" + #undef PRELU_TYPE + #undef PRELU_ELEMENT + + #define PRELU_OTHER prelu_other + #define PRELU_TYPE prelu_other + #include "ConvAddPrelu.inc.metal" + #undef PRELU_TYPE + #undef PRELU_OTHER + +#undef P + +#define P half + + #define PRELU_CHANNEL prelu_channel + #define PRELU_TYPE prelu_channel + #include "ConvAddPrelu.inc.metal" + #undef PRELU_TYPE + #undef PRELU_CHANNEL + + #define PRELU_ELEMENT prelu_element + #define PRELU_TYPE prelu_element + #include "ConvAddPrelu.inc.metal" + #undef PRELU_TYPE + #undef PRELU_ELEMENT + + #define PRELU_OTHER prelu_other + #define PRELU_TYPE prelu_other + #include "ConvAddPrelu.inc.metal" + #undef PRELU_TYPE + #undef PRELU_OTHER + +#undef P + + + + diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/FetchKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/FetchKernel.metal new file mode 100644 index 0000000000000000000000000000000000000000..c9d0624817d8508a3dae174e19a705b953d06101 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/FetchKernel.metal @@ -0,0 +1,71 @@ +/* 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. */ + +#include +using namespace metal; + +kernel void fetch(texture2d_array inTexture [[texture(0)]], + device float *output [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + + if (gid.x >= inTexture.get_width() || + gid.y >= inTexture.get_height() || + gid.z >= inTexture.get_array_size()) { + return; + } + + int input_width = inTexture.get_width(); + int input_height = inTexture.get_height(); + const float4 input = inTexture.read(gid.xy, gid.z); + int output_to = 4 * input_width * input_height; + output[gid.z * output_to + 0 * input_width * input_height + gid.y * input_width + gid.x] = input.x; + output[gid.z * output_to + 1 * input_width * input_height + gid.y * input_width + gid.x] = input.y; + output[gid.z * output_to + 2 * input_width * input_height + gid.y * input_width + gid.x] = input.z; + output[gid.z * output_to + 3 * input_width * input_height + gid.y * input_width + gid.x] = input.w; +} + + +kernel void fetch_half(texture2d_array inTexture [[texture(0)]], + device float * output [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + + if (gid.x >= inTexture.get_width() || + gid.y >= inTexture.get_height() || + gid.z >= inTexture.get_array_size()) { + return; + } + + int input_width = inTexture.get_width(); + int input_height = inTexture.get_height(); + const half4 input = inTexture.read(gid.xy, gid.z); + int output_to = 4 * input_width * input_height; + output[gid.z * output_to + 0 * input_width * input_height + gid.y * input_width + gid.x] = input.x; + output[gid.z * output_to + 1 * input_width * input_height + gid.y * input_width + gid.x] = input.y; + output[gid.z * output_to + 2 * input_width * input_height + gid.y * input_width + gid.x] = input.z; + output[gid.z * output_to + 3 * input_width * input_height + gid.y * input_width + gid.x] = input.w; + +} + +kernel void fetch_placeholder(texture2d_array inTexture [[texture(0)]], + device float *output [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + +} + +kernel void fetch_placeholder_half(texture2d_array inTexture [[texture(0)]], + device float *output [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { +} + + diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Macro.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Macro.metal new file mode 100644 index 0000000000000000000000000000000000000000..950d7d5f0555b841da57554ff61f2f5cdbcae7aa --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Macro.metal @@ -0,0 +1,29 @@ +/* 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. */ + +#include +using namespace metal; + + +#define CONCAT2(a, b) a ## b +#define CONCAT2_(a, b) a ## _ ## b +#define CONCAT3_(a, b, c) a ## _ ## b ## _ ## c +#define CONCAT4_(a, b, c, d) a ## _ ## b ## _ ## c ## _ ## d +#define CONCAT5_(a, b, c, d, e) a ## _ ## b ## _ ## c ## _ ## d ## _ ## e + +#define FUNC(f, r, n, v, p) CONCAT5_(f, r, n, v, p) +#define VECTOR(p, n) CONCAT2(p, n) + +#define FUNC3_(a, b, c) CONCAT3_(a, b, c) + diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/NMSFetchResultKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/NMSFetchResultKernel.metal new file mode 100644 index 0000000000000000000000000000000000000000..44c57440e1ec138717ad1bc569fd772e0d7ede1a --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/NMSFetchResultKernel.metal @@ -0,0 +1,80 @@ +/* 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. */ + +#include +using namespace metal; + +kernel void nms_fetch_result(texture2d_array inTexture [[texture(0)]], + device float *output [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + + if (gid.x >= inTexture.get_width() || + gid.y >= inTexture.get_height() || + gid.z >= inTexture.get_array_size()) { + return; + } + + int input_width = inTexture.get_width(); + const float4 input = inTexture.read(gid.xy, gid.z); + output[gid.y * input_width + gid.x] = input.x; + +} + + +kernel void nms_fetch_result_half(texture2d_array inTexture [[texture(0)]], + device float *output [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + + if (gid.x >= inTexture.get_width() || + gid.y >= inTexture.get_height() || + gid.z >= inTexture.get_array_size()) { + return; + } + + int input_width = inTexture.get_width(); + const half4 input = inTexture.read(gid.xy, gid.z); + output[gid.y * input_width + gid.x] = input.x; +} + +kernel void nms_fetch_bbox(texture2d_array inTexture [[texture(0)]], + device float4 *output [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + + if (gid.x >= inTexture.get_width() || + gid.y >= inTexture.get_height() || + gid.z >= inTexture.get_array_size()) { + return; + } + + int input_width = inTexture.get_width(); +// int input_height = inTexture.get_height(); + const float4 input = inTexture.read(gid.xy, gid.z); + output[gid.y * input_width + gid.x] = input; +} + +kernel void nms_fetch_bbox_half(texture2d_array inTexture [[texture(0)]], + device float4 *output [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + if (gid.x >= inTexture.get_width() || + gid.y >= inTexture.get_height() || + gid.z >= inTexture.get_array_size()) { + return; + } + + int input_width = inTexture.get_width(); +// int input_height = inTexture.get_height(); + const half4 input = inTexture.read(gid.xy, gid.z); + output[gid.y * input_width + gid.x] = float4(input); +} + diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/PriorBoxKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/PriorBoxKernel.metal index 794f0ea6770688f0468d9ab4f9716adf3e93dd0c..7630febf77210bb364f0191e8b10a5a6923d6c95 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/PriorBoxKernel.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/PriorBoxKernel.metal @@ -161,3 +161,207 @@ kernel void prior_box_half(texture2d_array inTexture [[textu } } + + +kernel void prior_box_MinMaxAspectRatiosOrder(texture2d_array inTexture [[texture(0)]], + texture2d_array outBoxTexture [[texture(1)]], + texture2d_array varianceTexture [[texture(2)]], + const device float *aspect_ratios [[buffer(0)]], + constant PriorBoxMetalParam ¶m [[buffer(1)]], + const device float4 *variances [[buffer(2)]], + uint3 gid [[thread_position_in_grid]]) { + if (gid.x >= outBoxTexture.get_width() || + gid.y >= outBoxTexture.get_height() || + gid.z >= outBoxTexture.get_array_size()) return; + + float center_x = (gid.x + param.offset) * param.stepWidth; + float center_y = (gid.y + param.offset) * param.stepHeight; + + float box_width, box_height; + + + + if (gid.z == 0) { + box_width = box_height = param.minSize / 2; + + float4 box; + box.x = (center_x - box_width) / param.imageWidth; + box.y = (center_y - box_height) / param.imageHeight; + box.z = (center_x + box_width) / param.imageWidth; + box.w = (center_y + box_height) / param.imageHeight; + + float4 res; + if (param.clip) { + res = fmin(fmax(box, 0.0), 1.0); + } else { + res = box; + } + + outBoxTexture.write(res, gid.xy, gid.z); + } + + if (gid.z == 1 && param.maxSizeSize > 0) { + + box_width = box_height = sqrt(param.minSize * param.maxSize) / 2; + float4 max_box; + max_box.x = (center_x - box_width) / param.imageWidth; + max_box.y = (center_y - box_height) / param.imageHeight; + max_box.z = (center_x + box_width) / param.imageWidth; + max_box.w = (center_y + box_height) / param.imageHeight; + + float4 res; + if (param.clip) { + res = min(max(max_box, 0.0), 1.0); + } else { + res = max_box; + } + outBoxTexture.write(res, gid.xy, gid.z); + } + + int aspect_to = 0; + if (param.maxSizeSize > 0) { + aspect_to = gid.z - 2; + } else { + aspect_to = gid.z - 1; + } + + + + + if (aspect_to >= 0 && aspect_to < int(param.aspecRatiosSize)) { + + int skip = 0; + for (int i = 0; i < aspect_to + 1; ++i) { + if (fabs(aspect_ratios[i] - 1.) < 1e-6) { + skip += 1; + } + } + aspect_to += skip; + + float ar = aspect_ratios[aspect_to]; + + box_width = param.minSize * sqrt(ar) / 2; + box_height = param.minSize / sqrt(ar) / 2; + float4 box; + box.x = (center_x - box_width) / param.imageWidth; + box.y = (center_y - box_height) / param.imageHeight; + box.z = (center_x + box_width) / param.imageWidth; + box.w = (center_y + box_height) / param.imageHeight; + + float4 res; + if (param.clip) { + res = fmin(fmax(box, 0.0), 1.0); + } else { + res = box; + } + + outBoxTexture.write(res, gid.xy, gid.z); + } + + float4 variance = variances[0]; + if (gid.z < param.numPriors) { + float4 variances_output; + variances_output.x = variance.x; + variances_output.y = variance.y; + variances_output.z = variance.z; + variances_output.w = variance.w; + varianceTexture.write(variances_output, gid.xy, gid.z); + } +} + + +kernel void prior_box_MinMaxAspectRatiosOrder_half(texture2d_array inTexture [[texture(0)]], + texture2d_array outBoxTexture [[texture(1)]], + texture2d_array varianceTexture [[texture(2)]], + const device half *aspect_ratios [[buffer(0)]], + constant PriorBoxMetalParam ¶m [[buffer(1)]], + const device float4 *variances [[buffer(2)]], + uint3 gid [[thread_position_in_grid]]) { + if (gid.x >= outBoxTexture.get_width() || + gid.y >= outBoxTexture.get_height() || + gid.z >= outBoxTexture.get_array_size()) return; + + float center_x = (gid.x + param.offset) * param.stepWidth; + float center_y = (gid.y + param.offset) * param.stepHeight; + + float box_width, box_height; + + + + if (gid.z == 0) { + box_width = box_height = param.minSize / 2; + + float4 box; + box.x = (center_x - box_width) / param.imageWidth; + box.y = (center_y - box_height) / param.imageHeight; + box.z = (center_x + box_width) / param.imageWidth; + box.w = (center_y + box_height) / param.imageHeight; + + float4 res; + if (param.clip) { + res = fmin(fmax(box, 0.0), 1.0); + } else { + res = box; + } + + outBoxTexture.write(half4(res), gid.xy, gid.z); + } + + if (gid.z == 1 && param.maxSizeSize > 0) { + + box_width = box_height = sqrt(param.minSize * param.maxSize) / 2; + float4 max_box; + max_box.x = (center_x - box_width) / param.imageWidth; + max_box.y = (center_y - box_height) / param.imageHeight; + max_box.z = (center_x + box_width) / param.imageWidth; + max_box.w = (center_y + box_height) / param.imageHeight; + + float4 res; + if (param.clip) { + res = min(max(max_box, 0.0), 1.0); + } else { + res = max_box; + } + outBoxTexture.write(half4(res), gid.xy, gid.z); + } + + int aspect_to = 0; + if (param.maxSizeSize > 0) { + aspect_to = gid.z - 2; + } else { + aspect_to = gid.z - 1; + } + + if (aspect_to > 0 && aspect_to < int(param.aspecRatiosSize) && fabs(aspect_ratios[aspect_to] - 1.) > 1e-6) { + float ar = aspect_ratios[aspect_to]; + + box_width = param.minSize * sqrt(ar) / 2; + box_height = param.minSize / sqrt(ar) / 2; + float4 box; + box.x = (center_x - box_width) / param.imageWidth; + box.y = (center_y - box_height) / param.imageHeight; + box.z = (center_x + box_width) / param.imageWidth; + box.w = (center_y + box_height) / param.imageHeight; + + float4 res; + if (param.clip) { + res = fmin(fmax(box, 0.0), 1.0); + } else { + res = box; + } + + outBoxTexture.write(half4(res), gid.xy, gid.z); + } + + float4 variance = variances[0]; + if (gid.z < param.numPriors) { + float4 variances_output; + variances_output.x = variance.x; + variances_output.y = variance.y; + variances_output.z = variance.z; + variances_output.w = variance.w; + varianceTexture.write(half4(variances_output), gid.xy, gid.z); + } +} + + diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.inc.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.inc.metal new file mode 100644 index 0000000000000000000000000000000000000000..82d512e7095007b61d18158a8b9d04071b2b492b --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.inc.metal @@ -0,0 +1,52 @@ +#ifdef P + +#define CONCAT2(a, b) a ## b +#define CONCAT2_(a, b) a ## _ ## b +#define CONCAT3_(a, b, c) a ## _ ## b ## _ ## c +#define CONCAT4_(a, b, c, d) a ## _ ## b ## _ ## c ## _ ## d + +#define FUNC(f, r1, r2, p) CONCAT4_(f, r1, r2, p) +#define VECTOR(p, n) CONCAT2(p, n) +#define FUNC_R(f, r) CONCAT2_(f, r) + +kernel void FUNC(reshape, RIN, ROUT, P)(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant ReshapeParam &rp [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + if (gid.x >= outTexture.get_width() || + gid.y >= outTexture.get_height() || + gid.z >= outTexture.get_array_size()) return; + + int oxyzn[4] = {int(gid.x), int(gid.y), int(gid.z), 0}, oabcd[4], ixyzn[4], iabcd[4]; + ReshapeParam lrp = rp; + int oC = lrp.odim[lrp.otrans[3]]; + int iC = lrp.idim[lrp.itrans[3]]; + int count = lrp.odim[0] * lrp.odim[1] * lrp.odim[2] * lrp.odim[3]; + VECTOR(P, 4) r; + for (int n = 0; n < 4; n++) { + oxyzn[3] = n; +#if ROUT == 4 + xyzn2abcd_4(oC, oxyzn, oabcd); +#else + FUNC_R(xyzn2abcd, ROUT)(oxyzn, oabcd); +#endif + int tabcd[4]; + invtrans(lrp.otrans, oabcd, tabcd); + int index = abcd2index(lrp.odim, tabcd); + if (index < count) { + index2abcd(lrp.idim, index, tabcd); + trans(lrp.itrans, tabcd, iabcd); +#if RIN == 4 + abcd2xyzn_4(iC, iabcd, ixyzn); +#else + FUNC_R(abcd2xyzn, RIN)(iabcd, ixyzn); +#endif + r[n] = inTexture.read(uint2(ixyzn[0], ixyzn[1]), ixyzn[2])[ixyzn[3]]; + } else { + r[n] = 0; + } + } + outTexture.write(r, gid.xy, gid.z); +} + +#endif diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.metal index 399287da71feb11b4e19167ced4f7fe4acdbf42a..d2f5815d422ec8c4f3e1e3c1992855547e002264 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.metal @@ -8,7 +8,7 @@ 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. + WITHOUT WARRANTIES OR CONRITIONS OF ANY KINR, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ @@ -24,114 +24,127 @@ struct ReshapeParam { int32_t otrans[4]; }; -//kernel void reshape(texture2d_array inTexture [[texture(0)]], -// texture2d_array outTexture [[texture(1)]], -// constant ReshapeParam &rp [[buffer(0)]], -// uint3 gid [[thread_position_in_grid]]) { -// if (gid.x >= outTexture.get_width() || -// gid.y >= outTexture.get_height() || -// gid.z >= outTexture.get_array_size()) return; -// -// int oxyzn[4] = {int(gid.x), int(gid.y), int(gid.z), 0}, oabcd[4], ixyzn[4]; -// ReshapeParam lrp = rp; -// int oC = lrp.odim[lrp.otrans[3]]; -// int iC = lrp.idim[lrp.itrans[3]]; -// int count = lrp.odim[0] * lrp.odim[1] * lrp.odim[2] * lrp.odim[3]; -// float4 r; -// for (int n = 0; n < 4; n++) { -// oxyzn[3] = n; -// -// //4 (gid.x gid.y, gid.z, 0~4) -// xyzn2abcd(oC, oxyzn, oabcd); -// int tabcd[4]; -// invtrans(lrp.otrans, oabcd, tabcd); -// int index = abcd2index(lrp.odim, tabcd); -// if (index < count) { -// int c = index % 4; -// -// int temp0 = index % (inTexture.get_array_size() * 4); -// int slice = temp0 / 4; -// -// int temp1 = index % (inTexture.get_array_size() * 4 * lrp.idim[2]); -// int w = temp1 / (inTexture.get_array_size() * 4); -// -// int h = index / (inTexture.get_array_size() * 4 * lrp.idim[2]); -// -//// index2abcd(lrp.idim, index, tabcd); -//// abcd2xyzn(iC, tabcd, ixyzn); -// r[n] = inTexture.read(uint2(w, h), slice)[c]; -// } else { -// r[n] = 0; -// } -// } -// outTexture.write(r, gid.xy, gid.z); -//} +#define P float +#define RIN 4 +#define ROUT 4 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 3 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 2 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 1 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#undef RIN +#define RIN 3 +#define ROUT 4 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 3 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 2 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 1 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#undef RIN +#define RIN 2 +#define ROUT 4 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 3 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 2 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 1 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#undef RIN +#define RIN 1 +#define ROUT 4 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 3 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 2 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 1 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#undef RIN -kernel void reshape(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - constant ReshapeParam &rp [[buffer(0)]], - uint3 gid [[thread_position_in_grid]]) { - if (gid.x >= outTexture.get_width() || - gid.y >= outTexture.get_height() || - gid.z >= outTexture.get_array_size()) return; +#undef P - int oxyzn[4] = {int(gid.x), int(gid.y), int(gid.z), 0}, oabcd[4], ixyzn[4], iabcd[4]; - ReshapeParam lrp = rp; - int oC = lrp.odim[lrp.otrans[3]]; - int iC = lrp.idim[lrp.itrans[3]]; - int count = lrp.odim[0] * lrp.odim[1] * lrp.odim[2] * lrp.odim[3]; - float4 r; - for (int n = 0; n < 4; n++) { - oxyzn[3] = n; - xyzn2abcd(oC, oxyzn, oabcd); - int tabcd[4]; - invtrans(lrp.otrans, oabcd, tabcd); - int index = abcd2index(lrp.odim, tabcd); - if (index < count) { - index2abcd(lrp.idim, index, tabcd); - trans(lrp.itrans, tabcd, iabcd); - abcd2xyzn(iC, iabcd, ixyzn); - r[n] = inTexture.read(uint2(ixyzn[0], ixyzn[1]), ixyzn[2])[ixyzn[3]]; - } else { - r[n] = 0; - } - } - outTexture.write(r, gid.xy, gid.z); -} +#define P half +#define RIN 4 +#define ROUT 4 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 3 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 2 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 1 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#undef RIN +#define RIN 3 +#define ROUT 4 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 3 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 2 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 1 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#undef RIN -kernel void reshape_half(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - constant ReshapeParam &rp [[buffer(0)]], - uint3 gid [[thread_position_in_grid]]) { - if (gid.x >= outTexture.get_width() || - gid.y >= outTexture.get_height() || - gid.z >= outTexture.get_array_size()) return; - - int oxyzn[4] = {int(gid.x), int(gid.y), int(gid.z), 0}, oabcd[4], ixyzn[4], iabcd[4]; - ReshapeParam lrp = rp; - int oC = lrp.odim[lrp.otrans[3]]; - int iC = lrp.idim[lrp.itrans[3]]; - int count = lrp.odim[0] * lrp.odim[1] * lrp.odim[2] * lrp.odim[3]; - half4 r; - for (int n = 0; n < 4; n++) { - oxyzn[3] = n; - xyzn2abcd(oC, oxyzn, oabcd); - int tabcd[4]; - invtrans(lrp.otrans, oabcd, tabcd); - int index = abcd2index(lrp.odim, tabcd); - if (index < count) { - index2abcd(lrp.idim, index, tabcd); - trans(lrp.itrans, tabcd, iabcd); - abcd2xyzn(iC, iabcd, ixyzn); - r[n] = inTexture.read(uint2(ixyzn[0], ixyzn[1]), ixyzn[2])[ixyzn[3]]; - } else { - r[n] = 0; - } - } - outTexture.write(r, gid.xy, gid.z); -} +#define RIN 2 +#define ROUT 4 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 3 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 2 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 1 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#undef RIN +#define RIN 1 +#define ROUT 4 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 3 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 2 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#define ROUT 1 +#include "ReshapeKernel.inc.metal" +#undef ROUT +#undef RIN +#undef P diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Shape.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Shape.metal new file mode 100644 index 0000000000000000000000000000000000000000..b50d5547193ccc9a1bef1b3ed6bbd1b7a64c3527 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Shape.metal @@ -0,0 +1,21 @@ +/* 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. */ + +#include +using namespace metal; + +kernel void shape() { +} +kernel void shape_half() { +} diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Softmax.inc.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Softmax.inc.metal new file mode 100644 index 0000000000000000000000000000000000000000..6c2d62a74ffaaca212c62bed08f0caeb1743b200 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Softmax.inc.metal @@ -0,0 +1,47 @@ +#ifdef P + +#define CONCAT2(a, b) a ## b +#define CONCAT2_(a, b) a ## _ ## b + +#define FUNC(f, p) CONCAT2_(f, p) +#define VECTOR(p, n) CONCAT2(p, n) + +kernel void FUNC(softmax, P)(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant SoftmaxParam &sp [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + if (gid.x >= outTexture.get_width() || + gid.y >= outTexture.get_height() || + gid.z >= outTexture.get_array_size()) return; +// int zsize = inTexture.get_array_size(); + P maxv = inTexture.read(uint2(0, gid.y), 0)[0]; + int group = sp.K / 4; + int remain = sp.K % 4; + for (int x = 0; x < group; x++) { + VECTOR(P, 4) r = inTexture.read(uint2(x, gid.y), 0); + maxv = max(maxv, max(r[0], max(r[1], max(r[2], r[3])))); + } + if (remain > 0) { + VECTOR(P, 4) r = inTexture.read(uint2(group, gid.y), 0); + for (int i = 0; i < remain; i++) { + maxv = max(maxv, r[i]); + } + } + VECTOR(P, 4) rsum = {0, 0, 0, 0}; + for (int x = 0; x < group; x++) { + VECTOR(P, 4) r = inTexture.read(uint2(x, gid.y), 0); + rsum += exp(r - maxv); + } + P sum = rsum[0] + rsum[1] + rsum[2] + rsum[3]; + if (remain > 0) { + VECTOR(P, 4) r = inTexture.read(uint2(group, gid.y), 0); + for (int i = 0; i < remain; i++) { + sum += exp(r[i] - maxv); + } + } + VECTOR(P, 4) rr = inTexture.read(gid.xy, gid.z); + rr = exp(rr - maxv) / sum; + outTexture.write(rr, gid.xy, gid.z); +} + +#endif diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Softmax.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Softmax.metal index 3442ba17ceee08d68b1f84642e00c56c5f73a4a2..67c279a4441095e710985c65d85aac589b7d0f54 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Softmax.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Softmax.metal @@ -20,81 +20,10 @@ struct SoftmaxParam { int K; }; -kernel void softmax(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - constant SoftmaxParam &sp [[buffer(0)]], - uint3 gid [[thread_position_in_grid]]) { - if (gid.x >= outTexture.get_width() || - gid.y >= outTexture.get_height() || - gid.z >= outTexture.get_array_size()) return; -// int zsize = inTexture.get_array_size(); - float maxv = inTexture.read(gid.xy, 0)[0]; - int group = sp.K / 4; - int remain = sp.K % 4; - for (int z = 0; z < group; z++) { - float4 r = inTexture.read(gid.xy, z); - maxv = max(maxv, max(r[0], max(r[1], max(r[2], r[3])))); - } - if (remain > 0) { - float4 r = inTexture.read(gid.xy, group); - for (int i = 0; i < remain; i++) { - maxv = max(maxv, r[i]); - } - } - float4 rsum = {0, 0, 0, 0}; - for (int z = 0; z < group; z++) { - float4 r = inTexture.read(gid.xy, z); - rsum += exp(r - maxv); - } - float sum = rsum[0] + rsum[1] + rsum[2] + rsum[3]; - if (remain > 0) { - float4 r = inTexture.read(gid.xy, group); - for (int i = 0; i < remain; i++) { - sum += exp(r[i] - maxv); - } - } - float4 rr = inTexture.read(gid.xy, gid.z); - rr = exp(rr - maxv) / sum; - outTexture.write(rr, gid.xy, gid.z); -} - -kernel void softmax_half(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - constant SoftmaxParam &sp [[buffer(0)]], - uint3 gid [[thread_position_in_grid]]) { - if (gid.x >= outTexture.get_width() || - gid.y >= outTexture.get_height() || - gid.z >= outTexture.get_array_size()) return; - // int zsize = inTexture.get_array_size(); - half maxv = inTexture.read(gid.xy, 0)[0]; - int group = sp.K / 4; - int remain = sp.K % 4; - for (int z = 0; z < group; z++) { - half4 r = inTexture.read(gid.xy, z); - maxv = max(maxv, max(r[0], max(r[1], max(r[2], r[3])))); - } - if (remain > 0) { - half4 r = inTexture.read(gid.xy, group); - for (int i = 0; i < remain; i++) { - maxv = max(maxv, r[i]); - } - } - float4 rsum = {0, 0, 0, 0}; - for (int z = 0; z < group; z++) { - half4 r = inTexture.read(gid.xy, z); - rsum += exp(float4(r) - float4(maxv)); - } - - float sum = rsum[0] + rsum[1] + rsum[2] + rsum[3]; - if (remain > 0) { - half4 r = inTexture.read(gid.xy, group); - for (int i = 0; i < remain; i++) { - sum += exp(float(r[i]) - float(maxv)); - } - } - - half4 rr = inTexture.read(gid.xy, gid.z); - rr = half4(exp(float4(rr) - float(maxv)) / sum); - outTexture.write(rr, gid.xy, gid.z); -} +#define P float +#include "Softmax.inc.metal" +#undef P +#define P half +#include "Softmax.inc.metal" +#undef P diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.inc.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.inc.metal new file mode 100644 index 0000000000000000000000000000000000000000..bd45f635223f10cf0a0c4acd818c66996f30b2cf --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.inc.metal @@ -0,0 +1,108 @@ +#ifdef P + +#define CONCAT2(a, b) a ## b +#define CONCAT2_(a, b) a ## _ ## b +#define CONCAT3_(a, b, c) a ## _ ## b ## _ ## c +#define CONCAT4_(a, b, c, d) a ## _ ## b ## _ ## c ## _ ## d +#define CONCAT5_(a, b, c, d, e) a ## _ ## b ## _ ## c ## _ ## d ## _ ## e + +#define FUNC(f, r, n, v, p) CONCAT5_(f, r, n, v, p) +#define VECTOR(p, n) CONCAT2(p, n) +#define FUNC_R(f, r) CONCAT2_(f, r) + +#if V == VX +#define VV x +#elif V == VY +#define VV y +#elif V == VZ +#define VV z +#else +#define VV normal +#endif + +#if V == VY +kernel void FUNC(split, R, N, VV, P)(texture2d_array input [[texture(0)]], + texture2d_array out1 [[texture(1)]], + texture2d_array out2 [[texture(2)]], +#if N >= 3 + texture2d_array out3 [[texture(3)]], +#endif // N >= 3 +#if N >= 4 + texture2d_array out4 [[texture(4)]], +#endif // N >= 4 + constant SplitParam &sp [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + + VECTOR(P, 4) r = input.read(gid.xy, gid.z); + int y = gid.y - sp.offset; + if (y < sp.vdim[0]) { + out1.write(r, gid.xy, gid.z); + return; + } + y -= sp.vdim[0]; + if (y < sp.vdim[1]) { + out2.write(r, uint2(gid.x, y), gid.z); + return; + } +#if N >= 3 + y -= sp.vdim[1]; + if (y < sp.vdim[2]) { + out3.write(r, uint2(gid.x, y), gid.z); + return; + } +#endif // N >= 3 +#if N >= 4 + y -= sp.vdim[2]; + if (y < sp.vdim[3]) { + out4.write(r, uint2(gid.x, y), gid.z); + return; + } +#endif // N >= 4 +} +#endif // V == VY + + +#if V == VX +kernel void FUNC(split, R, N, VV, P)(texture2d_array input [[texture(0)]], + texture2d_array out1 [[texture(1)]], + texture2d_array out2 [[texture(2)]], +#if N >= 3 + texture2d_array out3 [[texture(3)]], +#endif // N >= 3 +#if N >= 4 + texture2d_array out4 [[texture(4)]], +#endif // N >= 4 + constant SplitParam &sp [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + VECTOR(P, 4) r = input.read(gid.xy, gid.z); + int x = gid.x; + if (x < sp.vdim[0]) { + out1.write(r, gid.xy, gid.z); + return; + } + x -= sp.vdim[0]; + if (x < sp.vdim[1]) { + out2.write(r, uint2(x, gid.y), gid.z); + return; + } +#if N >= 3 + x -= sp.vdim[1]; + if (x < sp.vdim[2]) { + out3.write(r, uint2(x, gid.y), gid.z); + return; + } +#endif // N >= 3 +#if N >= 4 + x -= sp.vdim[2]; + if (x < sp.vdim[3]) { + out4.write(r, uint2(x, gid.y), gid.z); + return; + } +#endif // N >= 4 +} +#endif // V == VX + + + +#undef VV +#endif diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.metal index ccdaf47583d88302489f3a9d3c6922d454825b8a..4c1e818d2bf5c7266169f406fbfaf8e322685dc4 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.metal @@ -13,18 +13,52 @@ limitations under the License. */ #include +#include "Common.metal" + using namespace metal; -kernel void split(texture2d_array output[[texture(0)]], - uint3 gid [[thread_position_in_grid]]) { - float4 r; +struct SplitParam { + int32_t idim[4]; + int32_t axis; + int32_t offset; + int32_t trans[4]; + int32_t vdim[4]; +}; + +#define VNORMAL 1 +#define VX 2 +#define VY 3 +#define VZ 4 + +// only support split_{2, 3, 4}_{2, 3, 4}_y_{float, half} +// only support split_{3, 4}_{2, 3, 4}_x_{float, half} + + +//// ssd-ar: (R=3, N=2, V=y) +#define V VY + #define R 3 + #define N 2 + #define P float + #include "Split.inc.metal" + #undef P + #define P half + #include "Split.inc.metal" + #undef P + #undef N + #undef R +#undef V - output.write(r, gid.xy, gid.z); -} -kernel void split_half(texture2d_array output[[texture(0)]], - uint3 gid [[thread_position_in_grid]]) { - float4 r; - - output.write(half4(r), gid.xy, gid.z); -} +//// ssd-ar: (R=2, N=2, V=y) +#define V VY + #define R 2 + #define N 2 + #define P float + #include "Split.inc.metal" + #undef P + #define P half + #include "Split.inc.metal" + #undef P + #undef N + #undef R +#undef V diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/TransposeKernel.inc.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/TransposeKernel.inc.metal new file mode 100644 index 0000000000000000000000000000000000000000..fb21438d0463e913fde58649c6d60a7bf4aacd84 --- /dev/null +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/TransposeKernel.inc.metal @@ -0,0 +1,46 @@ +#ifdef P + +#define CONCAT2(a, b) a ## b +#define CONCAT2_(a, b) a ## _ ## b +#define CONCAT3_(a, b, c) a ## _ ## b ## _ ## c + +#define FUNC(f, r, p) CONCAT3_(f, r, p) +#define VECTOR(p, n) CONCAT2(p, n) + +kernel void FUNC(transpose, R, P)(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant TransposeParam &pm [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + VECTOR(P, 4) r; + int oxyzn[4] = {int(gid.x), int(gid.y), int(gid.z), 0}; + int iabcd[4], oabcd[4], ixyzn[4]; + for (int n = 0; n < 4; n++) { + oxyzn[3] = n; +#if R == 4 + xyzn2abcd_4(pm.oC, oxyzn, iabcd); +#endif // R == 4 +#if R == 3 + xyzn2abcd_3(oxyzn, oabcd); +#endif // R == 3 +#if R == 2 + xyzn2abcd_2(oxyzn, oabcd); +#endif // R == 2 + iabcd[pm.axis[0]] = oabcd[0]; + iabcd[pm.axis[1]] = oabcd[1]; + iabcd[pm.axis[2]] = oabcd[2]; + iabcd[pm.axis[3]] = oabcd[3]; +#if R == 4 + abcd2xyzn_4(pm.iC, iabcd, ixyzn); +#endif // R == 4 +#if R == 3 + abcd2xyzn_3(iabcd, ixyzn); +#endif // R == 3 +#if R == 2 + abcd2xyzn_2(iabcd, ixyzn); +#endif // R == 2 + r[n] = inTexture.read(uint2(ixyzn[0], ixyzn[1]), ixyzn[2])[ixyzn[3]]; + } + outTexture.write(r, gid.xy, gid.z); +} + +#endif diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/TransposeKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/TransposeKernel.metal index 4801f0315496ea65ff3ff51174e4e8086909aae8..321663b9b7f09eba2041cb0932215d291e44aba6 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/TransposeKernel.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/TransposeKernel.metal @@ -22,59 +22,42 @@ struct TransposeParam { int axis[4]; }; -kernel void transpose(texture2d_array inTexture [[texture(0)]], - texture2d_array outTexture [[texture(1)]], - constant TransposeParam &pm [[buffer(0)]], - uint3 gid [[thread_position_in_grid]]) { - - - if ((pm.axis[0] == 0) && (pm.axis[1] == 1) && (pm.axis[2] == 2) && (pm.axis[3] == 3)) { - // do nothing - float4 r = inTexture.read(gid.xy, gid.z); - outTexture.write(r, gid.xy, gid.z); - } else { - float4 r; - for (int n = 0; n < 4; n++) { - int ixyzn[] = {int(gid.x), int(gid.y), int(gid.z), n}; - int iabcd[4], oabcd[4], oxyzn[4]; - xyzn2abcd(pm.oC, ixyzn, iabcd); - oabcd[pm.axis[0]] = iabcd[0]; - oabcd[pm.axis[1]] = iabcd[1]; - oabcd[pm.axis[2]] = iabcd[2]; - oabcd[pm.axis[3]] = iabcd[3]; - abcd2xyzn(pm.iC, oabcd, oxyzn); - float4 rt = inTexture.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2]); - r[n] = rt[oxyzn[3]]; - } - outTexture.write(r, gid.xy, gid.z); - } +kernel void transpose_copy_float(texture2d_array inTexture [[texture(0)]], + texture2d_array outTexture [[texture(1)]], + constant TransposeParam &pm [[buffer(0)]], + uint3 gid [[thread_position_in_grid]]) { + outTexture.write(inTexture.read(gid.xy, gid.z), gid.xy, gid.z); } - -kernel void transpose_half(texture2d_array inTexture [[texture(0)]], +kernel void transpose_copy_half(texture2d_array inTexture [[texture(0)]], texture2d_array outTexture [[texture(1)]], constant TransposeParam &pm [[buffer(0)]], uint3 gid [[thread_position_in_grid]]) { - - - if ((pm.axis[0] == 0) && (pm.axis[1] == 1) && (pm.axis[2] == 2) && (pm.axis[3] == 3)) { - // do nothing - half4 r = inTexture.read(gid.xy, gid.z); - outTexture.write(r, gid.xy, gid.z); - } else { - half4 r; - for (int n = 0; n < 4; n++) { - int ixyzn[] = {int(gid.x), int(gid.y), int(gid.z), n}; - int iabcd[4], oabcd[4], oxyzn[4]; - xyzn2abcd(pm.oC, ixyzn, iabcd); - oabcd[pm.axis[0]] = iabcd[0]; - oabcd[pm.axis[1]] = iabcd[1]; - oabcd[pm.axis[2]] = iabcd[2]; - oabcd[pm.axis[3]] = iabcd[3]; - abcd2xyzn(pm.iC, oabcd, oxyzn); - half4 rt = inTexture.read(uint2(oxyzn[0], oxyzn[1]), oxyzn[2]); - r[n] = rt[oxyzn[3]]; - } - outTexture.write(r, gid.xy, gid.z); - } + outTexture.write(inTexture.read(gid.xy, gid.z), gid.xy, gid.z); } +#define R 4 + #define P float + #include "TransposeKernel.inc.metal" + #undef P + #define P half + #include "TransposeKernel.inc.metal" + #undef P +#undef R + +#define R 3 + #define P float + #include "TransposeKernel.inc.metal" + #undef P + #define P half + #include "TransposeKernel.inc.metal" + #undef P +#undef R + +#define R 2 + #define P float + #include "TransposeKernel.inc.metal" + #undef P + #define P half + #include "TransposeKernel.inc.metal" + #undef P +#undef R diff --git a/metal/paddle-mobile/paddle-mobile/Operators/MulticlassNMSOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/MulticlassNMSOp.swift index 6220a584e725042f454b02777a79caeaae2a52e1..bc7a8a64ab6a70ff8a14feb11cf7481d8f10cf7d 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/MulticlassNMSOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/MulticlassNMSOp.swift @@ -21,10 +21,16 @@ class MulticlassNMSParam: OpParam { scores = try MulticlassNMSParam.getFirstTensor(key: "Scores", map: opDesc.inputs, from: inScope) bboxes = try MulticlassNMSParam.getFirstTensor(key: "BBoxes", map: opDesc.inputs, from: inScope) output = try MulticlassNMSParam.outputOut(outputs: opDesc.outputs, from: inScope) + + middleOutput = FetchHolder.init(inCapacity: scores.tensorDim.numel(), inDim: scores.tensorDim.dims) + + bboxOutput = FetchHolder.init(inCapacity: bboxes.tensorDim.numel(), inDim: bboxes.tensorDim.dims) } catch let error { throw error } } + var bboxOutput: FetchHolder + var middleOutput: FetchHolder let scores: Texture

let bboxes: Texture

var output: Texture

@@ -33,7 +39,15 @@ class MulticlassNMSParam: OpParam { class MulticlassNMSOp: Operator, MulticlassNMSParam

>, Runable, Creator, InferShaperable{ func inputVariant() -> [String : [Variant]] { - return ["Scores" : [para.scores], "BBoxes" : [para.bboxes]] + return ["Scores" : [para.middleOutput], "BBoxes" : [para.bboxOutput]] + } + + func computeMiddleResult(device: MTLDevice, buffer: MTLCommandBuffer) { + do { + try kernel.compute(commandBuffer: buffer, param: para) + } catch let _ { + fatalError() + } } func inferShape() { @@ -42,11 +56,12 @@ class MulticlassNMSOp: Operator, Multic typealias OpType = MulticlassNMSOp

func runImpl(device: MTLDevice, buffer: MTLCommandBuffer) throws { - do { - try kernel.compute(commandBuffer: buffer, param: para) - } catch let error { - throw error - } + + } + + func delogOutput() { + print(" nms - output: ") + print(para.bboxes.metalTexture.float32Array().strideArray()) } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/PriorBoxOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/PriorBoxOp.swift index 4a27fba9839af5feb709a69a76529c60928a981e..c681eadcd19ab4f091d1fbb5e2e315492e0b8a49 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/PriorBoxOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/PriorBoxOp.swift @@ -17,6 +17,11 @@ import Foundation class PriorBoxParam: OpParam { typealias ParamPrecisionType = P required init(opDesc: OpDesc, inScope: Scope) throws { + do { + min_max_aspect_ratios_order = try PriorBoxParam.getAttr(key: "min_max_aspect_ratios_order", attrs: opDesc.attrs) + } catch _ { + } + do { input = try PriorBoxParam.input(inputs: opDesc.inputs, from: inScope) output = try PriorBoxParam.outputBoxes(outputs: opDesc.outputs, from: inScope) @@ -36,6 +41,7 @@ class PriorBoxParam: OpParam { } } + var min_max_aspect_ratios_order: Bool = false let minSizes: [Float32] let maxSizes: [Float32] let aspectRatios: [Float32] @@ -72,10 +78,24 @@ class PriorBoxOp: Operator, PriorBoxParam

print(" \(type) output: ") // output - let outputArray = para.output.metalTexture.float32Array() - print(outputArray) +// let outputArray = para.output.metalTexture.float32Array() +// print(outputArray.strideArray()) +// let device = para.input.metalTexture!.device +// let boxes:[Float32] = device.texture2tensor(texture: para.output.metalTexture!, dim: para.output.tensorDim.dims, transpose: [2,0,1,3]) +// let variances:[Float32] = device.texture2tensor(texture: para.outputVariances.metalTexture!, dim: para.outputVariances.tensorDim.dims, transpose: [2,0,1,3]) +// print("boxes: ") +// print(boxes.strideArray()) +// print("variances: ") +// print(variances.strideArray()) // output -// print(" \(type) output: ") + print(" \(type) output: ") + + let box = para.output.metalTexture.realNHWC(dim: (para.output.dim[0], para.output.dim[1], para.output.dim[2], para.output.dim[3])) + print(" dim: \(para.output.dim)") + print(box.strideArray()) +// print((0..: Operator, ReluParam

>, Runable, func delogOutput() { print(" \(type) output: ") print(para.output.metalTexture.toTensor(dim: (n: para.output.tensorDim[0], c: para.output.tensorDim[1], h: para.output.tensorDim[2], w: para.output.tensorDim[3])).strideArray()) + let device = para.output.metalTexture!.device + let outputArray: [Float32] = device.texture2tensor(texture: para.output.metalTexture, dim: para.output.tensorDim.dims, transpose: para.output.transpose) + print(outputArray.strideArray()) } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift index 1c1da9901d5740558d8cfd6363f2e96b15728556..ac46baca91bd6eedab9241da68a05d08391ec931 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift @@ -43,15 +43,12 @@ class ReshapeParam: OpParam { } output.padToFourDim = Dim.init(inDim: dim) output.dim = output.padToFourDim - -// inplace = try ReshapeParam.getAttr(key: "inplace", attrs: opDesc.attrs) } catch let error { throw error } } let input: Texture

let shape: [Int32] -// let inplace: Bool var output: Texture

} @@ -72,15 +69,9 @@ class ReshapeOp: Operator, ReshapeParam

>, } func delogOutput() { print("reshape delog") -// let _: P? = para.input.metalTexture.logDesc(header: "reshape input: ", stridable: false) -// -// let _: P? = para.output.metalTexture.logDesc(header: "reshape output: ", stridable: false) - let padToFourDim = para.output.padToFourDim - - let outputArray: [Float32] = para.output.metalTexture.realNHWC(dim: (n: padToFourDim[0], h: padToFourDim[1], w: padToFourDim[2], c: padToFourDim[3])) -// print(para.output.metalTexture.toTensor(dim: (n: padToFourDim[0], c: padToFourDim[1], h: padToFourDim[2], w: padToFourDim[3])).strideArray()) - + let device = para.output.metalTexture!.device + let outputArray: [Float32] = device.texture2tensor(texture: para.output.metalTexture, dim: para.output.tensorDim.dims, transpose: para.output.transpose) print(outputArray.strideArray()) - +// print(outputArray) } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ShapeOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ShapeOp.swift index 7af5562040d86d8c1b0989344650803d6c32975f..daebb37ade65893a8d77fc55e8f4706454176280 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ShapeOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ShapeOp.swift @@ -18,17 +18,19 @@ class ShapeParam: OpParam { typealias ParamPrecisionType = P required init(opDesc: OpDesc, inScope: Scope) throws { do { - output = try ShapeParam.output(outputs: opDesc.outputs, from: inScope) + input = try ShapeParam.input(inputs: opDesc.inputs, from: inScope) + output = try ShapeParam.outputOut(outputs: opDesc.outputs, from: inScope) } catch let error { throw error } } var output: Texture

+ let input: Texture

} -class ShapeOp: Operator, SplitParam

>, Runable, Creator, InferShaperable{ +class ShapeOp: Operator, ShapeParam

>, Runable, Creator, InferShaperable{ - typealias OpType = SplitOp

+ typealias OpType = ShapeOp

func inferShape() { // para.output.dim = para.input.dim diff --git a/metal/paddle-mobile/paddle-mobile/Operators/SplitOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/SplitOp.swift index 5adc47c663e5abd639f2cc2f4c95ae4c565e897a..7d26d6a38c696089a346165ad08d5ba655cffd59 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/SplitOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/SplitOp.swift @@ -18,13 +18,33 @@ class SplitParam: OpParam { typealias ParamPrecisionType = P required init(opDesc: OpDesc, inScope: Scope) throws { do { -// output = try SplitParam.output(outputs: opDesc.outputs, from: inScope) - output = try SplitParam.outputOut(outputs: opDesc.outputs, from: inScope) + input = try SplitParam.inputX(inputs: opDesc.inputs, from: inScope) + output = Texture

.init(device: input.metalTexture!.device, inDim: input.dim) + axis = try SplitParam.getAttr(key: "axis", attrs: opDesc.attrs) + sections = try SplitParam.getAttr(key: "sections", attrs: opDesc.attrs) + if axis < 0 { + axis = input.tensorDim.cout() + axis + } + guard let outlist = opDesc.outputs["Out"] else { + fatalError() + } + for out in outlist { + guard let variant = inScope[out], let v = variant as? Texture

else { + fatalError() + } + outputList.append(v) + sections.append(Int32(v.tensorDim.dims[axis])) + } } catch let error { throw error } } + + var axis: Int + let input: Texture

var output: Texture

+ var outputList: [Texture

] = [] + var sections: [Int32] = [] } class SplitOp: Operator, SplitParam

>, Runable, Creator, InferShaperable{ @@ -45,6 +65,11 @@ class SplitOp: Operator, SplitParam

>, Runabl func delogOutput() { print(" \(type) output: ") + let device = para.input.metalTexture!.device + for out in para.outputList { + let arr: [Float32] = device.texture2tensor(texture: out.metalTexture, dim: out.tensorDim.dims, transpose: out.transpose) + print(arr.strideArray()) + } } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/TransposeOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/TransposeOp.swift index 0213b52bf16fa498835729c5b7e3a65600f7669d..d7e75c42ce523024e8410f6e69a459b010c31357 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/TransposeOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/TransposeOp.swift @@ -48,15 +48,9 @@ class TransposeOp: Operator, TransposeParam func delogOutput() { print(" \(type) output: ") - let padToFourDim = para.output.padToFourDim - if para.output.transpose == [0, 1, 2, 3] { - let outputArray = para.output.metalTexture.realNHWC(dim: (n: padToFourDim[0], h: padToFourDim[1], w: padToFourDim[2], c: padToFourDim[3])) - print(outputArray.strideArray()) - } else if para.output.transpose == [0, 2, 3, 1] { - print(para.output.metalTexture.toTensor(dim: (n: para.output.tensorDim[0], c: para.output.tensorDim[1], h: para.output.tensorDim[2], w: para.output.tensorDim[3])).strideArray()) - } else { - print(" not implement") - } + let device = para.output.metalTexture!.device + let outputArray: [Float32] = device.texture2tensor(texture: para.output.metalTexture, dim: para.output.tensorDim.dims, transpose: para.output.transpose) + print(outputArray.strideArray()) } } diff --git a/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift b/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift index 1f67a0e5971957c79d452fe3c15449f297fb00d1..a8320342a450bceea676695d13d28501afb1889b 100644 --- a/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift +++ b/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift @@ -16,40 +16,15 @@ import Foundation class ScaleKernel: CusomKernel { init(device: MTLDevice, shape: Shape) { - super.init(device: device, inFunctionName: "scale_half", outputDim: shape, usePaddleMobileLib: false) - } -} - -public class Net: NSObject { - var except: Int = 0 - var means: [Float] = [] - var scale: Float = 0.0 - var dim: (n: Int, h: Int, w: Int, c: Int) = (n: 0, h: 0, w: 0, c: 0) - var preprocessKernel: CusomKernel? = nil - var paramPointer: UnsafeMutableRawPointer? = nil - var paramSize: Int = 0 - var modelPointer: UnsafeMutableRawPointer? = nil - var modelSize: Int = 0 - var modelPath: String = "" - var paramPath: String = "" - var modelDir: String = "" - public func resultStr(res: [Float]) -> String { - fatalError() - } - func fetchResult(paddleMobileRes: ResultHolder) -> [Float32] { - return paddleMobileRes.resultArr - } - @objc public init(device: MTLDevice) { - super.init() + if computePrecision == .Float32 { + super.init(device: device, inFunctionName: "scale", outputDim: shape, usePaddleMobileLib: false) + } else if computePrecision == .Float16 { + super.init(device: device, inFunctionName: "scale_half", outputDim: shape, usePaddleMobileLib: false) + } else { + fatalError(" unsupport ") + } } - @objc public init(device: MTLDevice,paramPointer: UnsafeMutableRawPointer, paramSize:Int, modePointer: UnsafeMutableRawPointer, modelSize: Int) { - self.paramPointer = paramPointer - self.paramSize = paramSize - self.modelPointer = modePointer - self.modelSize = modelSize - super.init() - } } public class Runner: NSObject { @@ -60,7 +35,7 @@ public class Runner: NSObject { public let net: Net let device: MTLDevice? let platform: Platform - var cpuPaddleMobile: PaddleMobile? + var cpuPaddleMobile: PaddleMobileCPU? let numel: Int let meansNumber: [NSNumber] @@ -80,7 +55,7 @@ public class Runner: NSObject { textureLoader = MTKTextureLoader.init(device: inDevice) } if platform == .CPU { - cpuPaddleMobile = PaddleMobile.init() + cpuPaddleMobile = PaddleMobileCPU.init() } numel = net.dim.n * net.dim.c * net.dim.h * net.dim.w meansNumber = net.means.map { NSNumber.init(value: $0) } @@ -101,8 +76,10 @@ public class Runner: NSObject { } let loader = Loader.init() do { - //program = try loader.load(device: inDevice, modelPath: net.modelPath, paraPath: net.paramPath) program = try loader.load(device: inDevice, paramPointer: net.paramPointer!, paramSize: net.paramSize,modePointer:net.modelPointer!,modelSize:net.modelSize) +// program = try loader.load(device: inDevice, modelPath: net.modelPath, paraPath: net.paramPath) + net.updateProgram(program: program!) + executor = try Executor.init(inDevice: inDevice, inQueue: inQueue, inProgram: program!) } catch let error { print(error) @@ -114,12 +91,13 @@ public class Runner: NSObject { return true } - @objc public func predict(inputPointer: UnsafeMutablePointer, completion: @escaping ( _ success: Bool, _ resultArray: [Float32]) -> Void) { - guard let res = cpuPaddleMobile?.predictInput(inputPointer, dim: dimsNum, means: meansNumber, scale: net.scale) else { - completion(false, []) + @objc public func predict(inputPointer: UnsafeMutablePointer, completion: @escaping ( _ success: Bool, _ result: PaddleMobileCPUResult?) -> Void) { + + guard let res = cpuPaddleMobile?.predictInput(inputPointer, dim: dimsNum) else { + completion(false, nil) return } - completion(true, res.map { ($0 as! NSNumber).floatValue }) + completion(true, res) } /** @@ -127,18 +105,18 @@ public class Runner: NSObject { * texture: 需要预测的 texture 需要做过预处理 * ( _ success: Bool, _ time:TimeInterval, _ resultArray: [Float32]) -> Void : 回调闭包, 三个参数分别为: 是否成功, 预测耗时, 结果数组 */ - @objc public func predict(texture: MTLTexture, completion: @escaping ( _ success: Bool, _ resultArray: [Float32]) -> Void) { + @objc public func predict(texture: MTLTexture, completion: @escaping ( _ success: Bool, _ result: ResultHolder?) -> Void) { do { try self.executor?.predict(input: texture, dim: [self.net.dim.n, self.net.dim.h, self.net.dim.w, self.net.dim.c], completionHandle: { [weak self] (res) in guard let SSelf = self else { fatalError( " self nil " ) } - let resultArray = SSelf.net.fetchResult(paddleMobileRes: res) - completion(true, resultArray) + let result = SSelf.net.fetchResult(paddleMobileRes: res) + completion(true, result) }, preProcessKernle: self.net.preprocessKernel, except: self.net.except) } catch let error { print(error) - completion(false, []) + completion(false, nil) return } } @@ -148,21 +126,21 @@ public class Runner: NSObject { * cgImage: 需要预测的图片 * ( _ success: Bool, _ time:TimeInterval, _ resultArray: [Float32]) -> Void : 回调闭包, 三个参数分别为: 是否成功, 预测耗时, 结果数组 */ - @objc public func predict(cgImage: CGImage, completion: @escaping ( _ success: Bool, _ resultArray: [Float32]) -> Void) { - if platform == .GPU { - getTexture(image: cgImage) { [weak self] (texture) in - guard let SSelf = self else { - fatalError( "" ) - } - SSelf.predict(texture: texture, completion: completion) - } - } else if platform == .CPU { - let input = preproccess(image: cgImage) - predict(inputPointer: input, completion: completion) - input.deinitialize(count: numel) - input.deallocate() - } - } +// @objc public func predict(cgImage: CGImage, completion: @escaping ( _ success: Bool, _ resultArray: [Float32]) -> Void) { +// if platform == .GPU { +// getTexture(image: cgImage) { [weak self] (texture) in +// guard let SSelf = self else { +// fatalError( "" ) +// } +// SSelf.predict(texture: texture, completion: completion) +// } +// } else if platform == .CPU { +// let input = preproccess(image: cgImage) +// predict(inputPointer: input, completion: completion) +// input.deinitialize(count: numel) +// input.deallocate() +// } +// } /* * 清理内存, 调用此函数后, 不能再使用, 需重新 load @@ -193,10 +171,10 @@ public class Runner: NSObject { */ @objc public func getTexture(image: CGImage, getTexture: @escaping (MTLTexture) -> Void) { let texture = try? textureLoader?.newTexture(cgImage: image, options: [:]) ?! " texture loader error" - scaleTexture(input: texture!, size: (net.dim.w, net.dim.h), complete: getTexture) + scaleTexture(input: texture!, complete: getTexture) } - func scaleTexture(input: MTLTexture, size:(width: Int, height: Int), complete: @escaping (MTLTexture) -> Void) { + public func scaleTexture(input: MTLTexture , complete: @escaping (MTLTexture) -> Void) { guard let inQueue = queue, let inDevice = device else { fatalError( " queue or devcie nil " ) @@ -206,7 +184,7 @@ public class Runner: NSObject { fatalError( " make buffer error" ) } - let scaleKernel = ScaleKernel.init(device: inDevice, shape: CusomKernel.Shape.init(inWidth: size.width, inHeight: size.height, inChannel: 3)) + let scaleKernel = ScaleKernel.init(device: inDevice, shape: CusomKernel.Shape.init(inWidth: net.dim.w, inHeight: net.dim.h, inChannel: 3)) do { try scaleKernel.compute(inputTexuture: input, commandBuffer: buffer) diff --git a/metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m b/metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m index 42a1b56507fde15f300c2e109ec50153638d3875..cb989123bb8edbe962959aa3e4438d67e98d05dc 100644 --- a/metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m +++ b/metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m @@ -43,7 +43,15 @@ } -(void)predict:(id)texture withCompletion:(void (^)(BOOL, NSArray *))completion { - [runner predictWithTexture:texture completion:completion]; + [runner predictWithTexture:texture completion:^(BOOL success, ResultHolder * _Nullable result) { + NSMutableArray *resultArray = [NSMutableArray arrayWithCapacity:result.capacity]; + for (int i = 0; i < result.capacity; ++i) { + [resultArray addObject:[NSNumber numberWithFloat:result.result[i]]]; + } + completion(success, resultArray); + + }]; +// [runner predictWithTexture:texture completion:completion]; } -(void)clear { diff --git a/metal/paddle-mobile/paddle-mobile/Program/BlockDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/BlockDesc.swift index f1a94e4e2af39c3d79681e1b41a13149e3a290fa..98dd7ff39a71cadfe6cc33f3d468448ac5155242 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/BlockDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/BlockDesc.swift @@ -14,7 +14,7 @@ import Foundation -struct BlockDesc { +class BlockDesc { let index: Int let parentIndex: Int let vars: [VarDesc] diff --git a/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift index 45f5d529503c7e985917a5e789b02b0bdbfc767e..44fc09a29db0deec67e7682b303b1d0947b47a51 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift @@ -14,7 +14,7 @@ import Foundation -struct OpDesc { +class OpDesc { let inputs: [String : [String]] var paraInputs: [String : [String]] var outputs: [String : [String]] diff --git a/metal/paddle-mobile/paddle-mobile/Program/Program.swift b/metal/paddle-mobile/paddle-mobile/Program/Program.swift index d8ded23a2c9e62543b35555b359d9049581a6923..464705d6db2b87945029de1bfcebddb1bfb4d092 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/Program.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/Program.swift @@ -14,7 +14,7 @@ import Foundation -public struct Program { +public class Program { let paramPath: String let programDesc: ProgramDesc let scope: Scope diff --git a/metal/paddle-mobile/paddle-mobile/Program/ProgramDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/ProgramDesc.swift index ef094a8a20790b4e0cf47eaea04bb7d4f7a2d046..ad472e5a7d1fe9db248e47f4417d7c61fb01eaa9 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/ProgramDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/ProgramDesc.swift @@ -14,7 +14,7 @@ import Foundation -public struct ProgramDesc { +public class ProgramDesc { var blocks: [BlockDesc] = [] init(protoProgram: PaddleMobile_Framework_Proto_ProgramDesc) { for block in protoProgram.blocks { diff --git a/metal/paddle-mobile/paddle-mobile/Program/ProgramOptimize.swift b/metal/paddle-mobile/paddle-mobile/Program/ProgramOptimize.swift index e744901a5ce7a0ac2363336fababc751024abd61..f6320be4cebcc30bacef9e92a3f40782a13ad68b 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/ProgramOptimize.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/ProgramOptimize.swift @@ -15,209 +15,272 @@ import Foundation precedencegroup ChainNode { - associativity: left - higherThan: MultiplicationPrecedence + associativity: left + higherThan: MultiplicationPrecedence } infix operator --> : ChainNode class Node { - var inputs: [Node] = [] - var outputs: [Node] = [] - var type: String - var opDesc: OpDesc? - init(inOpDesc: OpDesc) { - type = inOpDesc.type - opDesc = inOpDesc + var inputs: [Node] = [] + var outputs: [Node] = [] + var type: String + var opDesc: OpDesc? + init(inOpDesc: OpDesc) { + type = inOpDesc.type + opDesc = inOpDesc + } + + init(inType: String) { + type = inType + } + + subscript(index: Int) -> [Node] { + var nodes: [Node] = [] + getNodesWithLocation(index: index, nowIndex: 0, nodes: &nodes) + return nodes + } + + func getNodesWithLocation(index: Int, nowIndex: Int, nodes: inout [Node]) { + if index == nowIndex { + nodes.append(self) } - init(inType: String) { - type = inType + for output in outputs { + output.getNodesWithLocation(index: index, nowIndex: nowIndex + 1, nodes: &nodes) + } + } + + static func -->(lNode: Node, rNode: Node) -> Node { + lNode.outputs.append(rNode) + rNode.inputs.append(lNode) + return rNode + } + + func depth(begin: UInt = 1) -> UInt { + var beginMax: UInt = 1 + for output in outputs { + let subDepth = output.depth(begin: begin + 1) + beginMax = max(begin, subDepth) + } + beginMax = max(begin, beginMax) + return beginMax + } + + func to(depth: UInt) -> Node { + let beginNode = Node.init(inType: type) + to(depth: depth - 1, withNode: beginNode) + return beginNode + } + + func folderWith(fusion: Fusion.Type, removedNodes: inout [Node]) { + let fusionNode = fusion.fusionNode() + let change = fusion.change() + let inOutputs = outputs + outputs.removeAll() + opDesc?.outputs.removeAll() + for i in 0..(lNode: Node, rNode: Node) -> Node { - lNode.outputs.append(rNode) - rNode.inputs.append(lNode) - return rNode + for attr in inOpdesc.attrs { + beginNode.opDesc?.attrs[attr.key] = attr.value + // print(beginNode.opDesc?.attrs) } - func depth(begin: UInt = 1) -> UInt { - var beginMax: UInt = 1 - for output in outputs { - let subDepth = output.depth(begin: begin + 1) - beginMax = max(begin, subDepth) + for paraInput in inOpdesc.paraInputs { + if let inChanges = change[type] { + for keyChange in inChanges { + if keyChange.from == paraInput.key { + beginNode.opDesc?.paraInputs[keyChange.to] = paraInput.value + } else { + beginNode.opDesc?.paraInputs[paraInput.key] = paraInput.value + } } - beginMax = max(begin, beginMax) - return beginMax + } else { + beginNode.opDesc?.paraInputs[paraInput.key] = paraInput.value + } } - func to(depth: UInt) -> Node { - let beginNode = Node.init(inType: type) - to(depth: depth - 1, withNode: beginNode) - return beginNode + if matchNode.outputs.count == 0 { + beginNode.outputs.append(contentsOf: outputs) + beginNode.opDesc?.outputs = inOpdesc.outputs + } + removedNodes.append(self) - func folderWith(fusion: Fusion.Type, removedNodes: inout [Node]) { - let fusionNode = fusion.fusionNode() - let change = fusion.change() - let inOutputs = outputs - outputs.removeAll() - opDesc?.outputs.removeAll() - for i in 0.. [String : Node]{ + var map: [String : Node] = [:] + relationship(map: &map) + return map + } + + private func relationship(map: inout [String : Node]) { + guard let inOpDesc = opDesc else { + return } + for output in inOpDesc.outputs { + for outputKey in output.value { + map[outputKey] = self + } + } + for output in outputs { + output.relationship(map: &map) + } + } + } extension Node: Equatable { - static func == (lhs: Node, rhs: Node) -> Bool { - if lhs.outputs.count != rhs.outputs.count { - return false - } - - if lhs.type != rhs.type { - return false - } - - for i in 0.. Bool { + if lhs.outputs.count != rhs.outputs.count { + return false } + if lhs.type != rhs.type { + return false + } + + for i in 0.. { - // register fusion - let fusionOps: [Fusion.Type] = [ConvAddBatchNormReluOp

.self, - ConvAddOp

.self, - ConvBNReluOp

.self, - DwConvBNReluOp

.self] - - func optimize(originProgramDesc: ProgramDesc) -> ProgramDesc { - - guard originProgramDesc.blocks.count == 1 else { - fatalError(" not support yet") + // register fusion + let fusionOps: [Fusion.Type] = [ConvAddBatchNormReluOp

.self, + ConvAddPreluOp

.self, + ConvAddOp

.self, + ConvBNReluOp

.self, + DwConvBNReluOp

.self + ] + + func optimize(originProgramDesc: ProgramDesc) -> ProgramDesc { + + guard originProgramDesc.blocks.count == 1 else { + fatalError(" not support yet") + } + + var mapForNodeChain: [String : Node] = [:] + var nodes: [Node] = [] + var typeMapNodes: [String : [(node: Node, output: [String : Node])]] = [:] + let block = originProgramDesc.blocks[0] + for opDesc in block.ops { + guard let opInputKeys = opInfos[opDesc.type]?.inputs, let outputKeys = opInfos[opDesc.type]?.outputs else { + fatalError() + } + + let node = Node.init(inOpDesc: opDesc) + for inputKey in opInputKeys { + if let inputs = opDesc.inputs[inputKey] { + for input in inputs { + if let inputNode = mapForNodeChain[input] { + _ = inputNode --> node + } + } } - - var mapForNodeChain: [String : Node] = [:] - var nodes: [Node] = [] - var typeMapNodes: [String : [Node]] = [:] - let block = originProgramDesc.blocks[0] - for opDesc in block.ops { - guard let opInputKeys = opInfos[opDesc.type]?.inputs, let outputKeys = opInfos[opDesc.type]?.outputs else { - fatalError() - } - - let node = Node.init(inOpDesc: opDesc) - for inputKey in opInputKeys { - if let inputs = opDesc.inputs[inputKey] { - for input in inputs { - if let inputNode = mapForNodeChain[input] { - _ = inputNode --> node - } - } - } - } - - for outputKey in outputKeys { - if let outputs = opDesc.outputs[outputKey] { - for output in outputs { - mapForNodeChain[output] = node - } + } + + for outputKey in outputKeys { + if let outputs = opDesc.outputs[outputKey] { + for output in outputs { + mapForNodeChain[output] = node + } + } + } + + nodes.append(node) + + if var inNodes = typeMapNodes[opDesc.type] { + inNodes.append((node, mapForNodeChain)) + typeMapNodes[opDesc.type] = inNodes + } else { + typeMapNodes[opDesc.type] = [(node, mapForNodeChain)] + } + } + + for fusion in fusionOps { + let fusionNode = fusion.fusionNode() + let depth = fusionNode.depth() + if let toMatchNodes = typeMapNodes[fusionNode.type] { + for node in toMatchNodes { + + let toNode = node.node.to(depth: depth) + if toNode == fusionNode { // match + var canFolder = true + let relationshipMap = toNode.relationship() + + for toCheck in fusion.needCheck() { + // let nodes = toCheck + let checkNodes = toNode[toCheck.0] + + for checkNode in checkNodes { + let inputToChecks = checkNode.opDesc?.inputs[toCheck.1] ?? [] + for inputToCheck in inputToChecks { + if node.output[inputToCheck] == nil { + if relationshipMap[inputToCheck] == nil { + canFolder = false } + } } - - nodes.append(node) - - if var inNodes = typeMapNodes[opDesc.type] { - inNodes.append(node) - typeMapNodes[opDesc.type] = inNodes - } else { - typeMapNodes[opDesc.type] = [node] - } + } } - for fusion in fusionOps { - let fusionNode = fusion.fusionNode() - let depth = fusionNode.depth() - if let toMatchNodes = typeMapNodes[fusionNode.type] { - for node in toMatchNodes { - let toNode = node.to(depth: depth) - if toNode == fusionNode { // match - var removeNodes: [Node] = [] - node.folderWith(fusion: fusion, removedNodes: &removeNodes) - for removeNode in removeNodes { - nodes.remove(element: removeNode) - } - } - } - } + if !canFolder { + continue } - - var ops: [OpDesc] = [] - for node in nodes { - ops.append(node.opDesc!) + + var removeNodes: [Node] = [] + node.node.folderWith(fusion: fusion, removedNodes: &removeNodes) + for removeNode in removeNodes { + nodes.remove(element: removeNode) + } + } } - - var newProgramDesc = ProgramDesc.init() - let newBlock = BlockDesc.init(inVars: block.vars, inOps: ops) - newProgramDesc.blocks.append(newBlock) - return newProgramDesc + } } + + var ops: [OpDesc] = [] + for node in nodes { + ops.append(node.opDesc!) + } + + var newProgramDesc = ProgramDesc.init() + let newBlock = BlockDesc.init(inVars: block.vars, inOps: ops) + newProgramDesc.blocks.append(newBlock) + return newProgramDesc + } } diff --git a/metal/paddle-mobile/paddle-mobile/Program/TensorDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/TensorDesc.swift index d17f56cead5a40aede28c6bb76d77b6384aae552..1a72f5ef717063136c4708c881befd789a57219c 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/TensorDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/TensorDesc.swift @@ -14,7 +14,7 @@ import Foundation -struct TensorDesc { +class TensorDesc { let dims: [Int] let dataType: VarTypeType let dataLayout: DataLayout = DataLayout.NCHW() diff --git a/metal/paddle-mobile/paddle-mobile/Program/VarDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/VarDesc.swift index 58411828c0c94316da089fc1e2442c87bd154594..f29169598f69ec568bd9d08af8fa4738fe8f5eea 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/VarDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/VarDesc.swift @@ -56,7 +56,7 @@ enum VarTypeType: Int { } } -struct VarDesc { +class VarDesc { let name: String let persistable: Bool let type: VarTypeType diff --git a/metal/paddle-mobile/paddle-mobile/framework/Executor.swift b/metal/paddle-mobile/paddle-mobile/framework/Executor.swift index 595bf2e5b541e6465df4342cd2ba2f5362c9b086..db8a73be1fb0161a7da78c5f50ae5ab2c85f7a2b 100644 --- a/metal/paddle-mobile/paddle-mobile/framework/Executor.swift +++ b/metal/paddle-mobile/paddle-mobile/framework/Executor.swift @@ -14,39 +14,50 @@ import Foundation -let testTo = 3 + +let testTo = 81 + var isTest = false let computePrecision: ComputePrecision = .Float16 -public class ResultHolder { +public class GPUResultHolder { public let dim: [Int] - public let resultArr: [Float32] + public let capacity: Int + public var resultPointer: UnsafeMutablePointer? public var intermediateResults: [String : [Variant]]? public let elapsedTime: Double - public init(inDim: [Int], inResult: [Float32], inElapsedTime: Double, inIntermediateResults: [String : [Variant]]? = nil) { + public init(inDim: [Int], inPointer: UnsafeMutablePointer?, inCapacity: Int, inElapsedTime: Double, inIntermediateResults: [String : [Variant]]? = nil) { dim = inDim - resultArr = inResult + capacity = inCapacity + + if let inInPointer = inPointer { + resultPointer = UnsafeMutablePointer.allocate(capacity: inCapacity) + resultPointer?.initialize(from: inInPointer, count: inCapacity) + } + elapsedTime = inElapsedTime intermediateResults = inIntermediateResults } + } -extension ResultHolder: CustomDebugStringConvertible, CustomStringConvertible { +extension GPUResultHolder: CustomDebugStringConvertible, CustomStringConvertible { public var debugDescription: String { - var str = "" - str += "Dim: \(dim) \n value:[ " - if resultArr.count < 20 { - for d in resultArr { - str += " \(d) " - } - } else { - for d in stride(from: 0, to: resultArr.count, by: resultArr.count/20) { - str += " \(resultArr[d]) " - } - } - str += " ]" - return str +// var str = "" +// str += "Dim: \(dim) \n value:[ " +// if resultArr.count < 20 { +// for d in resultArr { +// str += " \(d) " +// } +// } else { +// for d in stride(from: 0, to: resultArr.count, by: resultArr.count/20) { +// str += " \(resultArr[d]) " +// } +// } +// str += " ]" +// return str + fatalError() } public var description: String { @@ -65,11 +76,23 @@ public class Executor { program = inProgram device = inDevice queue = inQueue +// print("before for ") +//print(program.scope.vars["fea_pyramid1_mbox_conf_flat.Flatten.output.1.tmp_0"]) + + for block in inProgram.programDesc.blocks { //block.ops.count for i in 0...shared.creat(device: inDevice, opDesc: op, scope: inProgram.scope) ops.append(op) } catch let error { @@ -79,7 +102,7 @@ public class Executor { } } - public func predict(input: MTLTexture, dim: [Int], completionHandle: @escaping (ResultHolder) -> Void, preProcessKernle: CusomKernel? = nil, except: Int = 0) throws { + public func predict(input: MTLTexture, dim: [Int], completionHandle: @escaping (GPUResultHolder) -> Void, preProcessKernle: CusomKernel? = nil, except: Int = 0) throws { guard let buffer = queue.makeCommandBuffer() else { throw PaddleMobileError.predictError(message: "CommandBuffer is nil") } @@ -101,7 +124,7 @@ public class Executor { let inputTexture = InputTexture.init(inMTLTexture: resInput, inExpectDim: Dim.init(inDim: dim)) program.scope.setInput(input: inputTexture) //(ops.count - except) - for i in 0.. { var outputTextures: [String : [Variant]]? if except > 0 { + ops[ops.count - except].computeMiddleResult(device: device, buffer: buffer) outputTextures = ops[ops.count - except].inputVariant() } buffer.addCompletedHandler { [weak self] (commandbuffer) in - // let inputArr = resInput.toTensor(dim: (n: dim[0], c: dim[3], h: dim[1], w: dim[2])) -//// print(inputArr.strideArray()) - -// print(dim) +// print(inputArr.strideArray()) +// +//// print(dim) // writeToLibrary(fileName: "test_image_ssd_ar", array: inputArr) - +// print(" write done ") + // print("write to library done") // return - // print(inputArr) - - // let stridableInput: [(index: Int, value: Float)] = input.stridableFloatArray() - // print(stridableInput) - - // let _: Flo? = input.logDesc(header: "input: ", stridable: true) -// for i in 0.. 0 { - resultHolder = ResultHolder.init(inDim: [], inResult: [], inElapsedTime: afterDate.timeIntervalSince(beforeDate), inIntermediateResults: outputTextures) + resultHolder = GPUResultHolder.init(inDim: [], inPointer: nil, inCapacity: 0, inElapsedTime: afterDate.timeIntervalSince(beforeDate), inIntermediateResults: outputTextures) } else { let outputVar: Variant = SSelf.program.scope.output()! - let output: Texture

= outputVar as! Texture

+ let output: FetchHolder = outputVar as! FetchHolder +// let beforeToTensorDate = Date.init() + + resultHolder = GPUResultHolder.init(inDim: output.dim, inPointer: output.result, inCapacity: output.capacity, inElapsedTime: afterDate.timeIntervalSince(beforeDate)) - resultHolder = ResultHolder.init(inDim: output.dim.dims, inResult: output.toTensor(), inElapsedTime: afterDate.timeIntervalSince(beforeDate)) +// let timeToTensor = Date.init().timeIntervalSince(beforeToTensorDate) +// print(timeToTensor) } completionHandle(resultHolder) diff --git a/metal/paddle-mobile/paddle-mobile/framework/Loader.swift b/metal/paddle-mobile/paddle-mobile/framework/Loader.swift index 71e6471add4aa20c66ba24d70875194b7966881c..ee640ddf1163bb1f41da49fe9089964321792d9f 100644 --- a/metal/paddle-mobile/paddle-mobile/framework/Loader.swift +++ b/metal/paddle-mobile/paddle-mobile/framework/Loader.swift @@ -214,7 +214,7 @@ public class Loader { } } else { if varDesc.name == fetchKey { - scope[varDesc.name] = ResultHolder.init(inDim: [], inResult: [], inElapsedTime: 0.0) +// scope[varDesc.name] = ResultHolder.init(inDim: [], inResult: [], inCapacity: <#Int#>, inElapsedTime: 0.0) } else if varDesc.name == feedKey { } }