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
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
7
1.3k
どうして手を動かすよりもチーム内のコードレビューを優先するべきなのか
okashoi
3
120
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
ドメインイベント増えすぎ問題
h0r15h0
2
350
103 Early Hints
sugi_0000
1
230
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
140
情報漏洩させないための設計
kubotak
3
300
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
720
テストコード書いてみませんか?
onopon
2
130
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
470
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
820
Featured
See All Featured
Docker and Python
trallard
42
3.1k
Speed Design
sergeychernyshev
25
670
Statistics for Hackers
jakevdp
796
220k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Mobile First: as difficult as doing things right
swwweet
222
9k
Why Our Code Smells
bkeepers
PRO
335
57k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Faster Mobile Websites
deanohume
305
30k
What's in a price? How to price your products and services
michaelherold
243
12k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
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ͷ͜ͱΕͯΑͦ͞͏ʢݸਓత݁ʣ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ