DLLAB Engineer Days 2019
Android/iOS端末における
エッジ推論のチューニング
竹村 伸太郎
株式会社バンダイナムコスタジオ
NE統括本部 NE技術本部 ネットワークシステム部 NEシステム4課
Tokyo Headquarters
BANDAI NAMCO Studios Inc.
エッジ推論
クラウド推論
エッジ推論 クラウド推論
Edge Cloud
Download
Upload
Computing… Computing…
エッジ推論(オフライン) クラウド推論(オフライン)
Edge Cloud
Disconnected
Computed
Vivino
20%
92%
世界一のワインアプリ「Vivino」、誕生のエピソード
リンク先をご覧くださ
い
Google Research Perception - CV4AR/VR
BlazeFace: Sub-millisecond Neural Face
Detection on Mobile GPUs, Google, 2019
• Lightweight but well-performing
• Tailored for mobile GPU inference
• 200–1000+ FPS on flagship devices
Real-time Facial Surface Geometry from
Monocular Video on Mobile GPUs, Google, 2019
• 3D human face mesh (468 vertices)
• Single camera input (no depth required)
• 100-1000 FPS on mobile GPUs
High-Quality AR Lipstick Simulation via
Image Filtering Techniques, Google, 2018
• 720p resolution
• 100+ FPS on mid-to-highend devices
リンク先をご覧ください
写真加工アプリFiuFiu(旧FaceU)の技術
Byted Effect 2.0, ByteDance AI Lab (以下、原文ママ)
2.0推出更多功能,可对人脸/人体/手指进行精准检测,为中小企业提
供多种移动端特效支持
注: Byted Effect 2.0 中所有能力均已接入抖音、Faceu等多个app使用
リンク先をご覧ください
ニューラルネットワークを用いたAIの格闘ゲームへの組み込み, SNK, GCC2019
Stadia - Introducing Style Transfer ML, Google, GDC2019
Behind the Scenes with Stadia’s Style Transfer ML, Google, 2019
リンク先をご覧ください
TEmporally COherent GAN for video super-resolution (TecoGAN), arXiv, 2019
リンク先をご覧ください
GIF2Video: Color Dequantization and Temporal Interpolation of GIF images, CVPR2019
リンク先をご覧ください
Optimize deep super-resolution and denoising for compressed textures, SIGGRAPH Asia 2018 Poster
720p
W1280 H720
360p
W640 H360
2X
OS Device SoC Framework API Average(ms) StdDev(ms)
Android 9 Pixel3a Snapdragon 670 Tensorflow Lite OpenCL 245.860 0.531
Android 9 Xperia1 Snapdragon 855 Tensorflow Lite OpenCL 67.469 0.646
iOS 12 iPhone XR A12 Bionic CoreML Metal 20.039 4.554
ゲーム業界特有の課題
Platform CPU Compiler
Ubuntu X86 GCC
Windows X86 Visual C++
Android ARM or X86 GCC
MacOS X X86 Clang
iOS ARM Clang
Platform CPU Compiler
Xbox One X86 Visual C++
PlayStation4 X86 Clang
Switch ARM Clang
理想的なDevOps/MLOpsの追求
DT01 ゲーム メーカー目線で Azure を活用した開発イン
フラのクラウド シフトとアプリ設計事例紹介
OSやデバイスによる推論速度の違い
0 100 200 300 400 500 600
Pixel3a (SDM670)
Zenfone5Z (SDM845)
Xperia1 (SDM855)
iPhone6S (A9)
iPhone7 (A10)
iPhone8 (A11)
iPhoneXR (A12)
iPhone11 (A13)
Pixel3a (SDM670) Zenfone5Z (SDM845) Xperia1 (SDM855) iPhone6S (A9) iPhone7 (A10) iPhone8 (A11) iPhoneXR (A12) iPhone11 (A13)
GPU-FP16 164 64 60 66 47 47 26 19
CPU-MT 227 147 102 159 110 97 92 74
CPU-ST 564 401 230 229 167 167 150 129
Tensorflow Lite Benchmark
GPU(Metal or OpenCL) / CPU(multi threads) / CPU(single thread)
GPU-FP16
CPU-MT
CPU-ST
推論速度について補足
Accurate 3D Face Reconstruction with Weakly-Supervised
Learning: From Single Image to Image Set
AI-SCHOLAR
顔画像から3Dメッシュをお手軽に再構築!
実写アバターは身近なものに?
BlazeFace: Sub-millisecond Neural Face Detection on
Mobile GPUs
リンク先をご覧ください
学習用フレームワークの選定
Automatic Differentiation in Swift, Google,
2018
Inference Engine Supported Mobile Platforms Tensor Format
Google Tensorflow Lite Android(CPU, GPU) / iOS(CPU, GPU) NHWC
Apple CoreML iOS(CPU, GPU) CHW *1
Microsoft ONNX Runtime Android(CPU) NCHW
Amazon Neo-AI DLR Android(CPU) NCHW
*1 CoreMLのインターフェースは、3次のテンソルを単数または複数指定する仕様となっている
Tensorflow
Tensorflow Mobile
(deprecated) Tensorflow Lite
OpenGL ES 3.1 for Android
Metal for iOS
OpenCL for
Android
TVM
Halide
MNN
Regular ConvolutionHeight
Depth
3
3
Input
Channels
Depth
Output
Channels
Kernel
計算内容
計算量
width, height, channel out, channel in, filter size
これを削減したい。どうしたらよいか?
Joseph E. Gonzalez, Model Compression, 2019
1x1 Convolution (Point Convolution)Height
Depth
1
1
Input
Channels
Depth
Output
Channels
計算内容
計算量
width, height, channel out, channel in
Depthwise (Separable) ConvolutionHeight
Depth
3
3
Input
Channels
Depth
Output Channels
=
Input Channels
計算内容
計算量
width, height, channel in, filter size
計算量の削減例
Height
3
3
1
1
Spatial
Aggregation
Channel
Aggregation
計算量
普通の畳み込みは、ここが掛け算
エッジ推論高速化の基本
FastDepth: Fast Monocular Depth Estimation on Embedded Systems, MIT, ICRA 2019
この領域でもTVMは強い!
おすすめツール
Microsoft WinML Dashboard
まとめ

Android/iOS端末におけるエッジ推論のチューニング