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
slidify-sample
shu223
1
1.2k
機械学習のブルーオーシャン Core ML by 堤 修一 #iOSDC Japan 2020
shu223
12
5.6k
エンジニアのための発信講座 #4 登壇しよう
shu223
0
120
エンジニアのための発信講座 #3
shu223
0
100
エンジニアのための発信講座 #2
shu223
2
220
エンジニアのための発信講座 #1
shu223
1
910
今こそwatchOS #iosdc
shu223
5
9.8k
Depth in Depth #iOSDC
shu223
4
29k
Metal Acceleratedかどうかを調べる方法〜あなたのアプリのどこでMetalが暗躍しているのか #potatotips
shu223
1
1.6k
Other Decks in Programming
See All in Programming
Spatial Rendering for Apple Vision Pro
warrenm
0
110
useSyncExternalStoreを使いまくる
ssssota
6
1.2k
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
720
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
940
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
260
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
780
From Translations to Multi Dimension Entities
alexanderschranz
2
130
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
840
ChatGPT とつくる PHP で OS 実装
memory1994
PRO
2
110
快速入門可觀測性
blueswen
0
380
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
How STYLIGHT went responsive
nonsquared
95
5.2k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Scaling GitHub
holman
458
140k
Documentation Writing (for coders)
carmenintech
66
4.5k
Agile that works and the tools we love
rasmusluckow
328
21k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Docker and Python
trallard
42
3.1k
4 Signs Your Business is Dying
shpigford
181
21k
A designer walks into a library…
pauljervisheath
204
24k
YesSQL, Process and Tooling at Scale
rocio
169
14k
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ͷ͜ͱΕͯΑͦ͞͏ʢݸਓత݁ʣ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ