提交 32efc50c 编写于 作者: X xiaohaichun 提交者: GitHub

Merge pull request #994 from xiaohaichun/metal

Metal
......@@ -87,3 +87,222 @@ metal/models/
metal/images/
*.a
metal/paddle-mobile/paddle-mobile/CPU/libpaddle-mobile.a
metal/paddle-mobile-demo/paddle-mobile-demo/images/banana.jpeg
metal/paddle-mobile-demo/paddle-mobile-demo/images/hand.jpg
metal/paddle-mobile-demo/paddle-mobile-demo/images/iphone.JPG
metal/paddle-mobile-demo/paddle-mobile-demo/images/paddle-mobile.png
metal/paddle-mobile-demo/paddle-mobile-demo/images/synset.txt
metal/paddle-mobile-demo/paddle-mobile-demo/models/genet/genet_model
metal/paddle-mobile-demo/paddle-mobile-demo/models/genet/genet_params
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenet/model
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenet/params
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenet_combine/model
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenet_combine/params
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenet_ssd_hand/ssd_hand_model
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenet_ssd_hand/ssd_hand_params
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/__model__
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_0.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_0.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_0.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_0.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_1.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_1.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_1.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_1.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_10.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_10.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_10.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_10.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_11.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_11.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_11.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_11.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_12.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_12.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_12.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_12.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_13.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_13.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_13.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_13.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_14.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_14.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_14.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_14.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_15.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_15.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_15.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_15.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_16.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_16.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_16.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_16.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_17.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_17.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_17.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_17.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_18.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_18.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_18.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_18.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_19.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_19.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_19.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_19.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_2.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_2.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_2.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_2.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_20.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_20.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_20.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_20.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_21.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_21.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_21.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_21.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_22.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_22.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_22.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_22.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_23.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_23.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_23.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_23.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_24.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_24.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_24.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_24.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_25.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_25.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_25.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_25.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_26.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_26.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_26.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_26.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_27.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_27.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_27.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_27.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_28.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_28.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_28.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_28.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_29.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_29.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_29.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_29.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_3.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_3.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_3.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_3.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_30.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_30.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_30.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_30.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_31.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_31.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_31.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_31.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_32.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_32.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_32.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_32.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_33.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_33.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_33.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_33.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_34.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_34.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_34.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_34.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_4.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_4.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_4.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_4.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_5.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_5.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_5.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_5.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_6.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_6.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_6.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_6.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_7.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_7.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_7.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_7.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_8.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_8.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_8.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_8.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_9.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_9.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_9.w_1
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/batch_norm_9.w_2
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_0.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_1.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_10.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_11.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_12.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_13.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_14.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_15.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_16.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_17.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_18.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_19.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_2.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_20.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_21.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_22.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_22.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_23.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_23.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_24.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_24.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_25.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_25.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_26.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_26.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_27.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_27.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_28.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_28.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_29.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_29.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_3.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_30.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_30.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_31.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_31.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_32.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_32.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_33.b_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_33.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_4.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_5.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_6.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_7.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_8.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/conv2d_9.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_0.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_1.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_10.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_11.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_12.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_2.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_3.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_4.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_5.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_6.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_7.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_8.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/mobilenetssd/depthwise_conv2d_9.w_0
metal/paddle-mobile-demo/paddle-mobile-demo/models/yolo/mobilenet
metal/paddle-mobile-demo/paddle-mobile-demo/models/yolo/model
metal/paddle-mobile-demo/paddle-mobile-demo/models/yolo/params
metal/paddle-mobile-demo/paddle-mobile-demo/models/yolo/yolo
metal/paddle-mobile-demo/paddle-mobile-demo/models/fluid_fssd_new_ar/ar_model
metal/paddle-mobile-demo/paddle-mobile-demo/models/fluid_fssd_new_ar/ar_params
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>paddle-mobile-demo.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>6</integer>
</dict>
</dict>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="4MS-jc-i6A">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
......@@ -50,10 +50,9 @@
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ZZh-fw-LwK">
<rect key="frame" x="0.0" y="20" width="225" height="247"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Platform:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2EB-m2-a3L">
<rect key="frame" x="10" y="538" width="68" height="24"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="749" text="Platform:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2EB-m2-a3L">
<rect key="frame" x="10" y="538" width="35" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="68" id="Q5J-tq-JSX"/>
<constraint firstAttribute="height" constant="24" id="SYv-As-Si8"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
......@@ -61,12 +60,12 @@
<nil key="highlightedColor"/>
</label>
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="DlO-dk-RMr">
<rect key="frame" x="88" y="510.5" width="287" height="80"/>
<rect key="frame" x="55" y="510.5" width="320" height="80"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="Sbi-05-Mwd"/>
</constraints>
</pickerView>
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6MG-gv-hD5">
<pickerView contentMode="scaleToFill" horizontalCompressionResistancePriority="749" translatesAutoresizingMaskIntoConstraints="NO" id="6MG-gv-hD5">
<rect key="frame" x="85" y="401" width="290" height="80"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="yAL-JY-G6b"/>
......@@ -75,7 +74,6 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Models" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="avL-VK-Kha">
<rect key="frame" x="10" y="429" width="65" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="65" id="6oA-g2-Xq4"/>
<constraint firstAttribute="height" constant="24" id="EwE-B3-z2R"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
......@@ -236,7 +234,76 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1127" y="-3"/>
<point key="canvasLocation" x="-1449" y="-3"/>
</scene>
<!--Load Pointer View Controller-->
<scene sceneID="56v-9i-I4d">
<objects>
<viewController id="4MS-jc-i6A" customClass="LoadPointerViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="VbZ-nk-rJR">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2p5-S3-M4T">
<rect key="frame" x="16" y="63" width="240" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="37q-nm-0H7">
<rect key="frame" x="38" y="610" width="42" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="ofW-G3-KST"/>
<constraint firstAttribute="width" constant="42" id="pwd-tO-zcJ"/>
</constraints>
<state key="normal" title="Image"/>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fAg-ai-yaA">
<rect key="frame" x="119" y="610" width="34" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="IES-jf-Z1n"/>
<constraint firstAttribute="width" constant="34" id="jxK-Xn-WCE"/>
</constraints>
<state key="normal" title="Load"/>
<connections>
<action selector="loaderButtonPressed:" destination="4MS-jc-i6A" eventType="touchUpInside" id="3cy-PD-aiE"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pdS-6e-Pd1">
<rect key="frame" x="185" y="610" width="49" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="49" id="ddY-uM-fzA"/>
<constraint firstAttribute="height" constant="30" id="yKd-YL-UML"/>
</constraints>
<state key="normal" title="Predict"/>
<connections>
<action selector="predictButtonPressed:" destination="4MS-jc-i6A" eventType="touchUpInside" id="sOH-iT-s1w"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DZa-sd-lY7">
<rect key="frame" x="279" y="610" width="34" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="34" id="aSO-4q-PgA"/>
<constraint firstAttribute="height" constant="30" id="eAt-Uc-BxX"/>
</constraints>
<state key="normal" title="clear"/>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="vsb-FH-h7h" firstAttribute="bottom" secondItem="37q-nm-0H7" secondAttribute="bottom" constant="27" id="4Wf-Uh-gvr"/>
<constraint firstItem="DZa-sd-lY7" firstAttribute="leading" secondItem="pdS-6e-Pd1" secondAttribute="trailing" constant="45" id="8dB-uI-cs9"/>
<constraint firstItem="fAg-ai-yaA" firstAttribute="leading" secondItem="37q-nm-0H7" secondAttribute="trailing" constant="39" id="EAV-Oq-jeD"/>
<constraint firstItem="vsb-FH-h7h" firstAttribute="bottom" secondItem="fAg-ai-yaA" secondAttribute="bottom" constant="27" id="Px0-A9-Eql"/>
<constraint firstItem="pdS-6e-Pd1" firstAttribute="leading" secondItem="fAg-ai-yaA" secondAttribute="trailing" constant="32" id="ZUR-Nv-aNb"/>
<constraint firstItem="vsb-FH-h7h" firstAttribute="bottom" secondItem="pdS-6e-Pd1" secondAttribute="bottom" constant="27" id="kPx-mt-ab9"/>
<constraint firstItem="37q-nm-0H7" firstAttribute="leading" secondItem="vsb-FH-h7h" secondAttribute="leading" constant="38" id="trH-Fq-sSv"/>
<constraint firstItem="vsb-FH-h7h" firstAttribute="bottom" secondItem="DZa-sd-lY7" secondAttribute="bottom" constant="27" id="yNJ-hq-2Qg"/>
</constraints>
<viewLayoutGuide key="safeArea" id="vsb-FH-h7h"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="hGb-Pb-icS" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-514" y="-3"/>
</scene>
</scenes>
<resources>
......
//
// LoadPointerViewController.h
// paddle-mobile-demo
//
// Created by Xiao,Haichun on 2018/9/19.
// Copyright © 2018年 orange. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LoadPointerViewController : UIViewController
@end
//
// LoadPointerViewController.m
// paddle-mobile-demo
//
// Created by Xiao,Haichun on 2018/9/19.
// Copyright © 2018年 orange. All rights reserved.
//
#import "LoadPointerViewController.h"
#import <Metal/Metal.h>
#import "paddle-mobile-demo-Bridging-Header.h"
@interface LoadPointerViewController ()
@property (strong, nonatomic) id<MTLDevice> device;
@property (strong, nonatomic) id<MTLTexture> texture;
@property (strong, nonatomic) id<MTLCommandQueue> queue;
@property (strong, nonatomic) PaddleMobileGPU *runner;
@property (strong, nonatomic) ModelConfig *modelConfig;
@end
@implementation LoadPointerViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.device = MTLCreateSystemDefaultDevice();
self.queue = [self.device newCommandQueue];
// Do any additional setup after loading the view.
NSString *modelPath = [[NSBundle mainBundle] URLForResource:@"genet_model" withExtension:nil].path;
NSString *paramPath = [[NSBundle mainBundle] URLForResource:@"genet_params" withExtension:nil].path;
long fileSize;
FILE *fp;
fp = fopen([modelPath UTF8String], "rb");
fseek(fp, 0, SEEK_END);
fileSize = ftell(fp);
rewind(fp);
void *buffer = malloc(fileSize);
fread(buffer, 1, fileSize, fp);
fclose(fp);
long paramfileSize;
FILE *parmaFilePointer;
parmaFilePointer = fopen([paramPath UTF8String], "rb");
fseek(parmaFilePointer, 0, SEEK_END);
paramfileSize = ftell(parmaFilePointer);
rewind(parmaFilePointer);
void *parmaBuffer = malloc(paramfileSize);
fread(parmaBuffer, 1, paramfileSize, parmaFilePointer);
fclose(parmaFilePointer);
_modelConfig = [[ModelConfig alloc] init];
_modelConfig.means = @[[NSNumber numberWithFloat:128.0], [NSNumber numberWithFloat:128.0], [NSNumber numberWithFloat:128.0]];
_modelConfig.scale = 0.017;
_modelConfig.dims = @[[NSNumber numberWithFloat:1], [NSNumber numberWithFloat:128.], [NSNumber numberWithFloat:128.0],[NSNumber numberWithFloat:3.0]];
_modelConfig.modelPointer = buffer;
_modelConfig.modelSize = (int)fileSize;
_modelConfig.paramPointer = parmaBuffer;
_modelConfig.paramSize = (int)paramfileSize;
}
- (IBAction)loaderButtonPressed:(id)sender {
_runner = [[PaddleMobileGPU alloc] initWithCommandQueue:self.queue net:GenetType modelConfig:_modelConfig];
[_runner load];
}
- (IBAction)predictButtonPressed:(id)sender {
[self predict];
}
- (id<MTLTexture>) createTextureFromImage:(UIImage*) image device:(id<MTLDevice>) device
{
image =[UIImage imageWithCGImage:[image CGImage]
scale:[image scale]
orientation: UIImageOrientationLeft];
NSLog(@"orientation and size and stuff %ld %f %f", (long)image.imageOrientation, image.size.width, image.size.height);
CGImageRef imageRef = image.CGImage;
size_t width = self.view.frame.size.width;
size_t height = self.view.frame.size.height;
size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef);
size_t bitsPerPixel = CGImageGetBitsPerPixel(imageRef);
CGColorSpaceRef colorSpace = CGImageGetColorSpace(imageRef);
CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);
// NSLog(@"%@ %u", colorSpace, alphaInfo);
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault | alphaInfo;
// NSLog(@"bitmap info %u", bitmapInfo);
CGContextRef context = CGBitmapContextCreate( NULL, width, height, bitsPerComponent, (bitsPerPixel / 8) * width, colorSpace, bitmapInfo);
if( !context )
{
NSLog(@"Failed to load image, probably an unsupported texture type");
return nil;
}
CGContextDrawImage( context, CGRectMake( 0, 0, width, height ), image.CGImage);
MTLPixelFormat format = MTLPixelFormatRGBA8Unorm;
MTLTextureDescriptor *texDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:format
width:width
height:height
mipmapped:NO];
id<MTLTexture> texture = [device newTextureWithDescriptor:texDesc];
[texture replaceRegion:MTLRegionMake2D(0, 0, width, height)
mipmapLevel:0
withBytes:CGBitmapContextGetData(context)
bytesPerRow:4 * width];
return texture;
}
- (void)predict {
_texture = [self createTextureFromImage:[UIImage imageNamed:@"hand.jpg"] device:self.device];
[_runner predict:_texture withCompletion:^(BOOL success , NSArray<NSNumber *> *result) {
if (success) {
for (int i = 0; i < result.count; i ++) {
NSNumber *number = result[i];
NSLog(@"result %d = %f:",i, [number floatValue]);
}
}
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
......@@ -2,6 +2,4 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//
//#import <paddle_mobile/>
#import <paddle_mobile/paddle_mobile.h>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>paddle-mobile-unit-test.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>5</integer>
</dict>
</dict>
</dict>
</plist>
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......
/* 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.
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FC039B6920E11C3C0081E9F8"
BuildableName = "paddle_mobile.framework"
BlueprintName = "paddle-mobile"
ReferencedContainer = "container:paddle-mobile.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FC039B6920E11C3C0081E9F8"
BuildableName = "paddle_mobile.framework"
BlueprintName = "paddle-mobile"
ReferencedContainer = "container:paddle-mobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FC039B6920E11C3C0081E9F8"
BuildableName = "paddle_mobile.framework"
BlueprintName = "paddle-mobile"
ReferencedContainer = "container:paddle-mobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>paddle-mobile.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
</dict>
</dict>
</dict>
</plist>
......@@ -26,6 +26,18 @@ public class Genet: Net {
preprocessKernel = GenetPreProccess.init(device: device)
dim = (n: 1, h: 128, w: 128, c: 3)
}
@objc override public init(device: MTLDevice,paramPointer: UnsafeMutableRawPointer, paramSize:Int, modePointer: UnsafeMutableRawPointer, modelSize: Int) {
super.init(device:device,paramPointer:paramPointer,paramSize:paramSize,modePointer:modePointer,modelSize:modelSize)
means = [128.0, 128.0, 128.0]
scale = 0.017
except = 0
modelPath = ""
paramPath = ""
modelDir = ""
preprocessKernel = GenetPreProccess.init(device: device)
dim = (n: 1, h: 128, w: 128, c: 3)
}
class GenetPreProccess: CusomKernel {
init(device: MTLDevice) {
......
......@@ -27,6 +27,18 @@ public class MobileNet_ssd_hand: Net{
dim = (n: 1, h: 300, w: 300, c: 3)
}
@objc override public init(device: MTLDevice,paramPointer: UnsafeMutableRawPointer, paramSize:Int, modePointer: UnsafeMutableRawPointer, modelSize: Int) {
super.init(device:device,paramPointer:paramPointer,paramSize:paramSize,modePointer:modePointer,modelSize:modelSize)
means = [123.68, 116.78, 103.94]
scale = 0.017
except = 2
modelPath = ""
paramPath = ""
modelDir = ""
preprocessKernel = MobilenetssdPreProccess.init(device: device)
dim = (n: 1, h: 300, w: 300, c: 3)
}
class MobilenetssdPreProccess: CusomKernel {
init(device: MTLDevice) {
let s = CusomKernel.Shape.init(inWidth: 300, inHeight: 300, inChannel: 3)
......
......@@ -16,15 +16,15 @@
import Foundation
public class ResultHolder: NSObject {
public let result: UnsafeMutablePointer<Float32>?
public let capacity: Int
@objc public let result: UnsafeMutablePointer<Float32>?
@objc public let capacity: Int
init(inResult: UnsafeMutablePointer<Float32>?, inCapacity: Int) {
result = inResult
capacity = inCapacity
}
public func releasePointer() {
@objc public func releasePointer() {
result?.deinitialize(count: capacity)
result?.deallocate()
}
......@@ -43,6 +43,14 @@ public class Net: NSObject {
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()
......
......@@ -24,6 +24,7 @@ class ScaleKernel: CusomKernel {
fatalError(" unsupport ")
}
}
}
public class Runner: NSObject {
......@@ -75,8 +76,10 @@ public class Runner: NSObject {
}
let loader = Loader<Float32>.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<Float32>.init(inDevice: inDevice, inQueue: inQueue, inProgram: program!)
} catch let error {
print(error)
......
......@@ -37,6 +37,7 @@ typedef enum : NSUInteger {
*/
@property (strong, nonatomic) NSArray<NSNumber *> *dims;
/*
* 模型参数内存地址
*/
......@@ -83,7 +84,7 @@ typedef enum : NSUInteger {
/*
* 清理内存
*/
-(void)clrear;
-(void)clear;
@end
......
......@@ -7,22 +7,56 @@
//
#import <Foundation/Foundation.h>
#import "PaddleMobileGPU.h"
#import "paddle_mobile/paddle_mobile-Swift.h"
#import "paddle_mobile.h"
#import <paddle_mobile/paddle_mobile-Swift.h>
@implementation ModelConfig
@end
@interface PaddleMobileGPU ()
{
Runner *runner;
}
@end
@implementation PaddleMobileGPU
-(void)clrear {
// [[ResultHolder alloc] init];
// [[TestClass alloc] init];
// [[TestClass alloc] initWithI:<#(NSInteger)#>]
// ResultHolder;
-(instancetype)initWithCommandQueue:(id<MTLCommandQueue>)queue net:(NetType)netType modelConfig:(ModelConfig *)config {
self = [super init];
if (self) {
Net *net = nil;
if (netType == GenetType) {
net = [[Genet alloc] initWithDevice:queue.device paramPointer:config.paramPointer paramSize:config.paramSize modePointer:config.modelPointer modelSize:config.modelSize];
} else if (netType == MobileNetSSDType) {
net = [[MobileNet_ssd_hand alloc] initWithDevice:queue.device paramPointer:config.paramPointer paramSize:config.paramSize modePointer:config.modelPointer modelSize:config.modelSize];
} else if (netType == MobileNetType) {
}
runner = [[Runner alloc] initInNet:net commandQueue:queue inPlatform:PlatformGPU];
}
return self;
}
@end
-(BOOL)load {
return [runner load];
}
-(void)predict:(id<MTLTexture>)texture withCompletion:(void (^)(BOOL, NSArray<NSNumber *> *))completion {
[runner predictWithTexture:texture completion:^(BOOL success, ResultHolder * _Nullable result) {
NSMutableArray<NSNumber *> *resultArray = [NSMutableArray arrayWithCapacity:result.capacity];
for (int i = 0; i < result.capacity; ++i) {
[resultArray addObject:[NSNumber numberWithFloat:result.result[i]]];
}
completion(success, resultArray);
[result releasePointer];
}];
// [runner predictWithTexture:texture completion:completion];
}
-(void)clear {
[runner clear];
}
@end
......@@ -23,4 +23,9 @@ public class Program {
paramPath = inParamPath
scope = inScope
}
init(inProgramDesc: ProgramDesc, inScope: Scope) {
programDesc = inProgramDesc
scope = inScope
paramPath = ""
}
}
......@@ -93,13 +93,57 @@ public class Loader<P: PrecisionType> {
fclose(file)
}
}
public init(){}
public func load(device: MTLDevice, modelPath: String, paraPath: String) throws -> Program{
class ParaLoaderWithPointer {
var paramPointer: UnsafeMutableRawPointer
let paramSize: Int
var nowIndex: Int
init(pPointer: UnsafeMutableRawPointer,pSize:Int) throws {
paramPointer = UnsafeMutableRawPointer.init(pPointer)
paramSize = pSize
nowIndex = 0
}
guard let modelData = try? Data.init(contentsOf: URL.init(fileURLWithPath: modelPath)) else {
throw PaddleMobileError.loaderError(message: "load " + modelPath + " failed !")
func read(tensor: Tensor<P>) throws {
guard nowIndex <= paramSize else {
throw PaddleMobileError.loaderError(message: "out of the file range")
}
var readerIndex: Int = 0
func pointerReader<T>(type: T.Type) -> T {
let ptr = UnsafeMutablePointer<T>.allocate(capacity: MemoryLayout<T>.size)
memcpy(ptr, paramPointer.advanced(by: Int(readerIndex)), MemoryLayout<T>.size)
nowIndex += MemoryLayout<T>.size
readerIndex += MemoryLayout<T>.size
let pointee = ptr.pointee
ptr.deinitialize(count: MemoryLayout<UInt32>.size)
ptr.deallocate()
return pointee
}
let _ = pointerReader(type: UInt32.self)
let lodLevel = pointerReader(type: UInt64.self)
for _ in 0..<lodLevel {
let size = pointerReader(type: UInt64.self)
for _ in 0..<Int(size/UInt64(MemoryLayout<size_t>.size)){
_ = pointerReader(type: size_t.self)
}
}
let _ = pointerReader(type: UInt32.self)
let tensorDescSize = pointerReader(type: Int32.self)
paramPointer = paramPointer.advanced(by: Int(readerIndex))
paramPointer = paramPointer.advanced(by: Int(tensorDescSize))
nowIndex += Int(tensorDescSize)
let _ = memcpy(tensor.data.pointer, paramPointer, tensor.data.size)
paramPointer = paramPointer.advanced(by: Int(tensor.data.size))
nowIndex += tensor.data.size
}
deinit {
}
}
public init(){}
func loadModelandParam(_ device:MTLDevice,_ modelData:Data, _ paraLoaderPointer:ParaLoaderWithPointer?, _ paraLoader:ParaLoader?) throws -> Program {
do {
let protoProgram = try PaddleMobile_Framework_Proto_ProgramDesc.init(
serializedData: modelData)
......@@ -108,10 +152,6 @@ public class Loader<P: PrecisionType> {
let programDesc = ProgramOptimize<P>.init().optimize(originProgramDesc: originProgramDesc)
print(programDesc)
guard let paraLoader = try? ParaLoader.init(paramPath: paraPath) else {
throw PaddleMobileError.loaderError(message: "load para error")
}
guard programDesc.blocks.count > 0 else {
throw PaddleMobileError.loaderError(message: "count of blocks must greater than 0")
}
......@@ -155,11 +195,17 @@ public class Loader<P: PrecisionType> {
let dim = Dim.init(inDim: dimArr)
let tensor = Tensor<P>.init(inDim: dim, inLayout: tensorDesc.dataLayout)
do {
try paraLoader.read(tensor: tensor)
if paraLoaderPointer != nil {
try paraLoaderPointer!.read(tensor: tensor)
}
if paraLoader != nil {
try paraLoader!.read(tensor: tensor)
}
} catch let error {
throw error
}
// tensor.convert(to: DataLayout.NHWC())
// tensor.convert(to: DataLayout.NHWC())
// tensor.initBuffer(device: device)
scope[varDesc.name] = tensor
} else {
......@@ -175,11 +221,39 @@ public class Loader<P: PrecisionType> {
}
}
let program = Program.init(inProgramDesc: programDesc, inParamPath: paraPath, inScope: scope)
let program = Program.init(inProgramDesc: programDesc, inScope: scope)
return program
} catch _ {
throw PaddleMobileError.loaderError(message: "protobuf decoder error")
}
}
public func load(device:MTLDevice, paramPointer: UnsafeMutableRawPointer, paramSize:Int, modePointer: UnsafeMutableRawPointer, modelSize: Int) throws -> Program {
let modelData = Data.init(bytes:modePointer, count:modelSize)
guard let paraLoader = try? ParaLoaderWithPointer.init(pPointer: paramPointer,pSize: paramSize) else {
throw PaddleMobileError.loaderError(message: "load para error")
}
do {
let program = try loadModelandParam(device,modelData,paraLoader,nil)
return program
} catch let error {
throw error
}
}
public func load(device: MTLDevice, modelPath: String, paraPath: String) throws -> Program{
guard let modelData = try? Data.init(contentsOf: URL.init(fileURLWithPath: modelPath)) else {
throw PaddleMobileError.loaderError(message: "load " + modelPath + " failed !")
}
guard let paraLoader = try? ParaLoader.init(paramPath: paraPath) else {
throw PaddleMobileError.loaderError(message: "load para error")
}
do {
let program = try loadModelandParam(device,modelData,nil,paraLoader)
return program
} catch let error {
throw error
}
}
}
......@@ -16,6 +16,7 @@
#import "PaddleMobile.h"
#import "CPUCompute.h"
#import "PaddleMobileGPU.h"
#import <UIKit/UIKit.h>
//! Project version number for paddle_mobile.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册