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.3k
機械学習のブルーオーシャン Core ML by 堤 修一 #iOSDC Japan 2020
shu223
12
5.6k
エンジニアのための発信講座 #4 登壇しよう
shu223
0
120
エンジニアのための発信講座 #3
shu223
0
110
エンジニアのための発信講座 #2
shu223
2
230
エンジニアのための発信講座 #1
shu223
1
920
今こそwatchOS #iosdc
shu223
5
9.9k
Depth in Depth #iOSDC
shu223
4
29k
Metal Acceleratedかどうかを調べる方法〜あなたのアプリのどこでMetalが暗躍しているのか #potatotips
shu223
1
1.6k
Other Decks in Programming
See All in Programming
最近のVS Codeで気になるニュース 2025/01
74th
1
110
Swiftコンパイラ超入門+async関数の仕組み
shiz
0
180
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
250
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
570
良いユニットテストを書こう
mototakatsu
11
3.6k
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
240
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
600
QA環境で誰でも自由自在に現在時刻を操って検証できるようにした話
kalibora
1
140
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
6
1.4k
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
630
rails newと同時に型を書く
aki19035vc
5
710
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
420
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
5
210
Faster Mobile Websites
deanohume
305
30k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
98
18k
How to Ace a Technical Interview
jacobian
276
23k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
Music & Morning Musume
bryan
46
6.3k
Thoughts on Productivity
jonyablonski
68
4.4k
Why Our Code Smells
bkeepers
PRO
335
57k
The Cost Of JavaScript in 2023
addyosmani
46
7.2k
Documentation Writing (for coders)
carmenintech
67
4.5k
The World Runs on Bad Software
bkeepers
PRO
66
11k
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ͷ͜ͱΕͯΑͦ͞͏ʢݸਓత݁ʣ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ