Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Core ML vs MPS vs BNNS #fincwwdc
Search
shu223
July 24, 2017
Programming
3
5.7k
Core ML vs MPS vs BNNS #fincwwdc
2017.7.24 WWDC2017振り返り勉強会@FiNC
での発表資料です。
shu223
July 24, 2017
Tweet
Share
More Decks by shu223
See All by shu223
GPT-4o with iOS
shu223
0
29
WhisperKit がだいぶ良いので紹介する
shu223
0
95
Animating Shapes with Simple Equations
shu223
0
17
ローカルLLM on iOS の現状まとめ
shu223
0
52
ARKit in visionOS
shu223
0
7
Core ML版Stable DiffusionをiOSで快適に動かす
shu223
0
52
iOSではじめるフォトグラメトリ #iOSDC
shu223
0
18
MLOps for Core ML #iOSDC 2022
shu223
0
11
slidify-sample
shu223
1
1.2k
Other Decks in Programming
See All in Programming
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2k
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
960
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
100
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
CSC509 Lecture 12
javiergs
PRO
0
160
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
CSC509 Lecture 13
javiergs
PRO
0
110
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
690
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Documentation Writing (for coders)
carmenintech
65
4.4k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Embracing the Ebb and Flow
colly
84
4.5k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
What's new in Ruby 2.0
geeforr
343
31k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
What's in a price? How to price your products and services
michaelherold
243
12k
Transcript
Core ML vs MPSCNN vs BNNS Shuichi Tsutsumi @shu223
!!!Core ML!!!
None
Core MLͷηογϣϯ Ұ൪େ͖͍ձͰ΄΅ຬһ
ਖ਼ࣜϦϦʔεલʹͯ͠طʹଟ͘ͷਓ͕ʹ
ͪΐɺͪΐͬͱͬͯ
ଞͷػցֶशπʔϧͰֶशͨ͠ϞσϧΛ iOSΞϓϦʹ͖࣋ͬͯͯʮਪʯΛߦ͏
ଞͷػցֶशπʔϧͰֶशͨ͠ϞσϧΛ iOSΞϓϦʹ͖࣋ͬͯͯʮਪʯΛߦ͏ → ͜Εࣗମ iOS 10 ͔ΒͰ͖ͨ
Metal Performance Shaders Accelerate (BNNS) Core ML Vision Your App
Metal Performance Shaders Accelerate (BNNS) Core ML Vision Your App
iOS 11
Metal Performance Shaders Accelerate (BNNS) Core ML Vision Your App
iOS 11 iOS 10
Metal Performance Shaders Accelerate (BNNS) Your App iOS 10
Metal Performance Shaders Accelerate (BNNS) Your App iOS 10
Metal Performance Shaders Accelerate (BNNS) Your App iOS 10 ͜ΕͰOK
Metal Performance Shaders Accelerate (BNNS) Your App iOS 10 •
iOS 10Ͱ͑Δ • વMetalͰॲཧ͞ΕΔʢMPSCNNͷ߹ʣ • ֶशଆɺTensorFlowͰKerasͰجຊతʹԿͰOK ͜ΕͰOK
͏ਖ਼ࣜϦϦʔε͔Β1ۙ͘ܦͭͷʹ ΄ͱΜͲʹͳͬͯͳ͍
ʢ୭͔ͷʣʮલ͔Β͋ΔͬͯͷΘ͔ͬͯ ·͢ΑɻͰMPSCNNͬͯػցֶशϑ ϨʔϜϫʔΫ͔Βॻ͖ग़ͨ͠Ϟσϧͷωο τϫʔΫͷߏ·ͰಡΜͰ͘Εͳ͍Ͱ͠ΐʁ ͰɺࣗͰͦ͜Λ࣮͢ΔΜͰ͠ΐʁͦΜ ͳͷΊΜͲͯͬͯ͘͘͞ΒΕͳ͍Ͱ͢Αʯ
͜Εͦͷ௨Γ
ͨͩɺ • ͜Ε΄Ͳͷͷ͕ࠩɺMPSCNNͷ۩ମతͳ͔ܽΒདྷ͍ͯΔͱࢥ͑ͳ͍ • ୯ʹʮMPSCNNͰʰͦΕʱ͕Ͱ͖Δʯͱ͍͏͜ͱ͕ΒΕ͍ͯͳ͔͚ͬͨͩͰʁ • ͔֬ʹɺใݯ͕Appleͷαϯϓϧ͙Β͍͔͠ͳ͔ͬͨ
࣮खॱ͕໌ࣔ͞ΕͯΕͬͱ͏ਓ͕ग़ͯ͘Δ ͷͰͳ͍͔ʁ ʢগͳ͘ͱCore MLʹڵຯ͕͋Δਓͪ͜Βݕ౼ͯ͠Έ͍͍ͯͣʣ ࣮खॱʢΘ͔ͬͯΈΕʣҙ֎ͱγϯϓϧ
MPSCNNΛ༻͍ͨػցֶशػೳͷ ࣮खॱ ̏εςοϓ
Step 1: ϞσϧΛͭ͘Δ
ֶशπʔϧɿͳΜͰ͍͍ Train ʢ˞$//ͷֶश͕Ͱ͖ͯύϥϝʔλΛॻ͖ग़ͤΔͷͰ͋Εʣ
ֶशπʔϧɿͳΜͰ͍͍ ϞσϧͷϑΥʔϚοτɿͳΜͰ͍͍ Train Model (Trained Params) dat or hdf5 •
χϡʔϥϧωοτϫʔΫͷʮॏΈʯ ͱʮόΠΞεʯͱ͍͏ύϥϝʔλ͕ ೖ͍ͬͯΔ • datͨͩͷόΠφϦϑΝΠϧ • iOSΞϓϦͰಡΈࠐΊ͑͢͞Εͳ ΜͰ͍͍ ʢ˞$//ͷֶश͕Ͱ͖ͯύϥϝʔλΛॻ͖ग़ͤΔͷͰ͋Εʣ
Step 2: ωοτϫʔΫΛ࣮͢Δ
None
MPSCNNConvolution MPSCNNFullyConnected MPSCNNPooling MPSCNNConvolution MPSCNNConvolution MPSCNNPooling
MPSCNNConvolution MPSCNNFullyConnected MPSCNNPooling MPSCNNConvolution MPSCNNConvolution MPSCNNPooling CNNͷ֤ʹରԠͨ͠Ϋϥε͕MPSʹ༻ҙ͞Ε͍ͯΔ
MPSCNNConvolution MPSCNNFullyConnected MPSCNNPooling MPSCNNConvolution MPSCNNConvolution MPSCNNPooling CNNͷ֤ʹରԠͨ͠Ϋϥε͕MPSʹ༻ҙ͞Ε͍ͯΔ • Convolution Layer
-> MPSCNNConvolution ͱ໊લͦͷ··ͳͷͰɺ࣮ʹͦΕ ΄Ͳ໎͏͜ͱͳ͍ • ͍͜͠ߦྻܭࢉɺGPUͰͷฒྻԋࢉͷ࠷దԽΛࣗͰҙࣝ͢Δඞཁͳ͍ • Step1Ͱֶͭͬͨ͘शࡁΈύϥϝʔλϑΝΠϧ͔ΒಡΜͰ͖ͯϙΠϯλΛ͢
Step 3: ਪͷ࣮ߦॲཧΛॻ͘
Input image MPSImage Result (UInt, etc.) CNN • Step 2Ͱ࣮ͨ͠ωοτϫʔΫ
• Step 1Ͱֶͭͬͨ͘शࡁΈϞσϧ ʢύϥϝʔλʣΛಡΈࠐΜͰ͍Δ Do something
؆୯ͦ͏Ͱ͠ΐʁ
MPSCNNͰ࣮ͨ͠ Swiftϩΰೝࣝ • MPSCNNͳͷͰiOS 10Ͱಈ͘
BUT
ϩΰೝࣝͷωοτϫʔΫ
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ)
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ) ஈҧ͍ʹෳࡶ
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ)) MPSCNNΛ༻͍ͨAppleʹΑΔެ࣮ࣜ
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ)) MPSCNNΛ༻͍ͨAppleʹΑΔެ࣮ࣜ
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ)) MPSCNNΛ༻͍ͨAppleʹΑΔެ࣮ࣜ
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ)) MPSCNNΛ༻͍ͨAppleʹΑΔެ࣮ࣜ
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ)) MPSCNNΛ༻͍ͨAppleʹΑΔެ࣮ࣜ
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ)) MPSCNNΛ༻͍ͨAppleʹΑΔެ࣮ࣜ
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ)) MPSCNNΛ༻͍ͨAppleʹΑΔެ࣮ࣜ
GoogLeNet (Inception v3: Ұൠମೝࣝ༻ͷϞσϧ)) MPSCNNΛ༻͍ͨAppleʹΑΔެ࣮ࣜ 3,000ߦ" ʢωοτϫʔΫ෦͚ͩͰʣ
͜ΕҎ֎ʹ • ػցֶशπʔϧଆͰόΠφϦϑΝΠϧΛॻ͖ग़͢Α͏ʹ͢ΔͷଟগΊΜͲ͍͘͞ • ֶशࡁΈύϥϝʔλͷೖͬͨόΠφϦσʔλΛಡΈࠐΜͰϙΠϯλΛ͢ͱ͔Cͬ Ά͍࣮͕ඞཁ • ೖग़ྗͷࡍʹMPSImageͱ͍͏ΫϥεΛѻ͏ඞཁ͕͋Γɺೖྗը૾Λมͨ͠Γ ਪ݁ՌΛऔΓग़ͨ͠Γ͢ΔࡍʹMetalͷϨΠϠʔͰΞϨίϨ͢Δඞཁ͕͋Δ
͜ΕҎ֎ʹ • ػցֶशπʔϧଆͰόΠφϦϑΝΠϧΛॻ͖ग़͢Α͏ʹ͢ΔͷଟগΊΜͲ͍͘͞ • ֶशࡁΈύϥϝʔλͷೖͬͨόΠφϦσʔλΛಡΈࠐΜͰϙΠϯλΛ͢ͱ͔Cͬ Ά͍࣮͕ඞཁ • ೖग़ྗͷࡍʹMPSImageͱ͍͏ΫϥεΛѻ͏ඞཁ͕͋Γɺೖྗը૾Λมͨ͠Γ ਪ݁ՌΛऔΓग़ͨ͠Γ͢ΔࡍʹMetalͷϨΠϠʔͰΞϨίϨ͢Δඞཁ͕͋Δ →
֓೦γϯϓϧ͕ͩͬͺΓ৭ʑΊΜͲ͍͘͞
Core MLπʔϧͰมͯ͠Xcodeϓϩ δΣΫτʹυϥοάˍυϩοϓ͢Δ͚ͩʂ
VisionΛ͑CIImageܕͰೖྗͰ ͖ɺ݁ՌͷऔΓग़͠؆୯ → MetalϨΠϠʹҰλον͢Δඞཁͳ͠
ͦ͏͍͏Θ͚Ͱ
Metal Performance Shaders Accelerate (BNNS) Your App iOS 10
Metal Performance Shaders Accelerate (BNNS) Core ML Vision Your App
iOS 11 iOS 10
ͬͺΓ͋Γ͕͍ͨ###
·ͱΊ • Core ML͕͜Μͳʹܴ͞ΕͯΔͷʹʮࠓ͙͢ϦϦʔε൛Ͱ͑ ΔʯMPSCNN͕͋·Γʹͳͬͯͳ͍ - ใ͕গͳ͘ɺ͍ํ͕Θͬͯͳ͍͚ͩͰͳ͍͔ • MPSCNNΛར༻࣮ͨ͠खॱ3εςοϓ -
Ϟσϧ࡞ˠωοτϫʔΫ࣮ˠਪ࣮ߦ - େہతʹΈΕҙ֎ͱγϯϓϧʹ͑Δ - ͔͠͠ਖ਼ͳͱ͜Ζେมͳ෦͋Δ • ͦ͜Λܶతʹ؆୯ʹͨ͠ͷ͕Core ML & Vision
͝ਗ਼ௌ͋Γ͕ɾɾɾ
Core ML vs MPSCNN vs BNNS
Εͯͨɾɾɾ Metal Performance Shaders Accelerate (BNNS) Core ML Vision Your
App
CNN on CPU?$
WWDC17ͷMetalϥϘͰฉ͍ͯΈ·ͨ͠ ʮͲ͏ͬͯMPSCNNͱBNNSΛ͍ ͚ͨΒ͍͍ͷʁʯ
ʮجຊతʹMPSCNNͬͯΕ͍͍Αʯ %
ʮ͑ͬɺ͡Ό͋BNNS͍ͭ͏ͷʁʯ
“I don’t know.” %
• ͦͷޙɺʮ͋ɺͰApple WatchGPUͳ͍͔ΒɺwatchOSͱ͔ BNNSͷ͍Ͳ͜Ζ͔Ͷʯͱݴͬͯͨ • ಈ͘ɺͱ͍͕ͬͯ͢͞ʹ⌚ͰϚγϯύϫʔ͕͖͍ͭͷͰͳ͍͔ ͱʢ˞࣮ػͰࢼͨ͜͠ͱͳ͍Ͱ͢ʣ • খ͍͞ωοτϫʔΫͰBNNSͷํ͕͔ͬͨͱ͍͏هࣄݟͨ͜ͱ͕ ͋Δʢ+25%ʣ
• جຊతʹ BNNSͷ͜ͱΕͯΑͦ͞͏ʢݸਓత݁ʣ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ