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
PLDI '21論文読み会: DNNFusion: Accelerating Deep Neu...
Search
Idein
June 08, 2022
Research
1
1.8k
PLDI '21論文読み会: DNNFusion: Accelerating Deep Neural Networks Execution with Advanced Operator Fusion
Idein
June 08, 2022
Tweet
Share
More Decks by Idein
See All by Idein
PLDI '21論文読み会: AKG: Automatic Kernel Generation for Neural Processing Units using Polyhedral Transformations
ideininc
0
1.6k
PLDI '21論文読み会: Specification Synthesis with Constrainted Horn Clauses
ideininc
0
1.5k
PLDI '21論文読み会: Cyclic Program Synthesis
ideininc
0
1.5k
PLDI '21論文読み会: High Performance Correctly Rounded Math Libraries for 32-bit Floating Point Representations
ideininc
0
1.5k
PLDI '21論文読み会: Quantum Abstract Interpretation
ideininc
0
1.5k
PLDI '21論文読み会: Provable Repair of Deep Neural Networks
ideininc
2
1.7k
会社紹介資料/Idein株式会社
ideininc
0
43k
Other Decks in Research
See All in Research
生成的推薦の人気バイアスの分析:暗記の観点から / JSAI2025
upura
0
230
【緊急警告】日本の未来設計図 ~沈没か、再生か。国民と断行するラストチャンス~
yuutakasan
0
140
Large Language Model Agent: A Survey on Methodology, Applications and Challenges
shunk031
14
9.5k
Type Theory as a Formal Basis of Natural Language Semantics
daikimatsuoka
1
270
最適化と機械学習による問題解決
mickey_kubo
0
160
Combinatorial Search with Generators
kei18
0
530
一人称視点映像解析の最先端(MIRU2025 チュートリアル)
takumayagi
6
3.1k
Delta Airlines® Customer Care in the U.S.: How to Reach Them Now
bookingcomcustomersupportusa
0
110
LLM-as-a-Judge: 文章をLLMで評価する@教育機関DXシンポ
k141303
3
850
心理言語学の視点から再考する言語モデルの学習過程
chemical_tree
2
540
Cross-Media Information Spaces and Architectures
signer
PRO
0
230
Self-supervised audiovisual representation learning for remote sensing data
satai
3
250
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
184
22k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
110
19k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Designing for Performance
lara
610
69k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
How to Ace a Technical Interview
jacobian
278
23k
Transcript
DNNFusion: Accelerating Deep Neural Networks Execution with Advanced Operator Fusion
Wei Niu1, Jiexiong Guan1, Yanzhi Wang2, Gagan Agrawal1, and Bin Ren1 1: William & Mary 2: Northeastern University 一言でまとめると: Operator Fusionのパターンを一般化すること で 汎用性と最適化性能を上げた 担当:bonotake 2021/9/17, PLDI2021読み会@Idein 2022/06/08 PLDI2021読み会@Idein 1
背景:Operator Fusion • DNNコンパイルでは一般的な最適化パスの1つ • 著者らの経験から、DNN実行時間にはレイヤー数が 極めてクリティカルに効く → operator fusion
は効果的 しかし、従来手法は汎用性の低さに問題があった • Polyhedral analysis → 抽象度が低い • 特定のパターンによるパターンマッチ(TVMなど) → パターンが極めて限定的 2022/06/08 PLDI2021読み会@Idein 2
提案手法:DNNFusion 1. GenericなパターンでFusionするかを判断 • 各オペレータにmapping typeという型を導入 • 組み合わせの “収益性” (profitability)
を導入 • 型の組み合わせ+収益性のあるなしでfusionするかを判断 2. Extended Computational Graph (ECG) の導入 • 普通のCG + mapping type 3. 代数的な性質に基づいたグラフ書き換え 4. Mapping type に基づいた fusion plan generation 実験の結果 • モバイル端末(Galaxy S20)上でTVMの1.5~3.5倍、TFLiteの1.4~3.3倍高速化 • 従来のコンパイラでは非対応だったネットワーク(Faster R-CNNなど)も モバイル端末で動かせるように 2022/06/08 PLDI2021読み会@Idein 3
Mapping type とは • 入力/出力の組が1対1か、1対多か、多対多かで分類したもの • 多対1(convなど)は多対多に分類 • 他に Reorganlize,
Shuffle が存在 2022/06/08 PLDI2021読み会@Idein 4
Mapping type analysis • 接続されている2オペレータの組み合わせをmapping type を基に解析 • 緑:無条件にfusion •
赤:fusionしない • オレンジ:収益性があればfusion Table 3 より 2022/06/08 PLDI2021読み会@Idein 5
収益性 • Mapping typeの組み合わせによっては、fusionするとレイテ ンシが落ちるものがある • そういう場合、fusionすると収益性がある(profitable)かど うかで実際にfusionするかを判断する • 収益性はコストを実測してのプロファイルベースに判断
• Profiling database をあらかじめ持っておくことで効率化可能 • 例:多対多オペレータの後ろにConv(多対1)がある場合 • Expandの場合、1次元の拡張だけなので恐らく悪い影響はない • Resizeの場合、入力を違う次元にコピーするので悪影響があり得る 2022/06/08 PLDI2021読み会@Idein 6
DNNFusionの処理 1. ECGを作成 2. グラフ書き換え 3. Fusion plan の探索・生成 4.
ブロック内最適化 5. コード生成 6. ブロック間最適化 2022/06/08 PLDI2021読み会@Idein 7
グラフ書き 換え • 基本的な代数的性質(結合則、分配則、可換則)に 基づいたグラフの書き換え • strength reduction (のテンソル版)によって書 き換えを判断
2022/06/08 PLDI2021読み会@Idein 8 Figure 2 より
Fusion Plan の探索 • アルゴリズム 1. ECG上で、起点となるオペレータ(seed)を1つ決める • one-to-one オペレータのうち、生成する中間結果のサイズが最小のものを選ぶ
2. 後続のオペレータ(successor)とfusionできるか考える 1. Mapping type で判断できるならそれで 2. 判断できないなら収益性で 3. Fusionできる場合、更に後続ともfusionできるか、再帰的に判定 4. 前につながるオペレータ(predecessor)ともfusion可能か再帰的 に判定 • ただし、successorとは違って複数の候補の1つとだけしかfusionしない 5. unfusedなオペレータがあったら、その中で1からまたやる 2022/06/08 PLDI2021読み会@Idein 9
最適化とコード生成 1. ブロック内最適化 • Shuffle、Reorganizeは大抵 消せるし、それも後続のオペ レータ1つだけ見れば判断がつ く 2022/06/08 PLDI2021読み会@Idein
10 2. コード生成 3. ブロック間最適化 • データレイアウトはここでやる • ブロック内は、その中で“支配的”なオペレータのレイアウトに合わせる
評価1: レイヤー数 • Sumsung Galaxy S20で、レイヤー数をどこまで削減できるかを他のコンパイラ/フ レームワークと比較 • 結果、 •
TVMの1/1.3~1/8.1に削減 • TFLiteの1/1.3~1/8.8に削減 • PyTorch mobileの1/1.6~1/9.3に削減 2022/06/08 PLDI2021読み会@Idein 11
評価2: レイテンシ • 速度が • TVMの1.5~2.5倍 • TFLiteの1.4~3.3倍 • PyTorch
mobileの1.6~9.3倍 • TransformerベースはTVMと比較して特に効果大 • TVMのパターンがハマらないものが多い 2022/06/08 PLDI2021読み会@Idein 12 その他の結果は論文読んでね
まとめ • Operator Fusionのパターンを一般化することで 汎用性と最適化性能を上げた • Mapping type の導入とパターンの整理 •
収益性の導入 • 代数的なグラフ書き換え規則 など 所感 • 特別凄いことはやってないが、みんな悩んでたところをちゃんと整理してまと めたのがエライ • 方向性は正しいように思える • 一部なんかようわからんところがあったけど • ちゃんと結果も出てるしすごい 2022/06/08 PLDI2021読み会@Idein 13