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.8k
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.4k
機械学習のブルーオーシャン Core ML by 堤 修一 #iOSDC Japan 2020
shu223
12
5.8k
エンジニアのための発信講座 #4 登壇しよう
shu223
0
140
エンジニアのための発信講座 #3
shu223
0
130
エンジニアのための発信講座 #2
shu223
2
250
エンジニアのための発信講座 #1
shu223
1
990
今こそwatchOS #iosdc
shu223
5
10k
Depth in Depth #iOSDC
shu223
4
29k
Metal Acceleratedかどうかを調べる方法〜あなたのアプリのどこでMetalが暗躍しているのか #potatotips
shu223
1
1.6k
Other Decks in Programming
See All in Programming
🔨 小さなビルドシステムを作る
momeemt
1
500
『リコリス・リコイル』に学ぶ!! 〜キャリア戦略における計画的偶発性理論と変わる勇気の重要性〜
wanko_it
1
590
State of CSS 2025
benjaminkott
1
120
Scale out your Claude Code ~自社専用Agentで10xする開発プロセス~
yukukotani
9
2.6k
ワープロって実は計算機で
pepepper
2
1.4k
サーバーサイドのビルド時間87倍高速化
plaidtech
PRO
0
480
学習を成果に繋げるための個人開発の考え方 〜 「学習のための個人開発」のすすめ / personal project for leaning
panda_program
1
110
[FEConf 2025] 모노레포 절망편, 14개 레포로 부활하기까지 걸린 1년
mmmaxkim
0
990
Claude Codeで実装以外の開発フロー、どこまで自動化できるか?失敗と成功
ndadayo
2
1.4k
モバイルアプリからWebへの横展開を加速した話_Claude_Code_実践術.pdf
kazuyasakamoto
0
260
DockerからECSへ 〜 AWSの海に出る前に知っておきたいこと 〜
ota1022
5
1.8k
Portapad紹介プレゼンテーション
gotoumakakeru
1
130
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
49
14k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.6k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
30
9.6k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
Building Adaptive Systems
keathley
43
2.7k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
What's in a price? How to price your products and services
michaelherold
246
12k
Navigating Team Friction
lara
189
15k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.4k
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ͷ͜ͱΕͯΑͦ͞͏ʢݸਓత݁ʣ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ