SlideShare ist ein Scribd-Unternehmen logo
1 von 57
Downloaden Sie, um offline zu lesen
J O S E P H
S P I S A K
P R O D U C T
M A N A G E R
P Y T O R C H | O N D E V I C E
OVERVIEW AND INTEGRATION
PYTORCH MOBILE
STATE OF THE STATE
ON DEVICE
DYNAMIC VS. STATIC
FRAMEWORKS
PRINCIPLES, MAKEUP, ..
OVERVIEW
REIMPLEMENTATIONTAKESWEEKSORMONTHS
Research to Production at Facebook – Early 2017
ENABLINGMODELORMODELFRAGMENTTRANSFER
Research to Production at Facebook – Early 2018
Research to Production at Facebook
P Y T O R C H
O V E R V I E W
SIMPLICITY
OVER
COMPLEXITY
HARDWARE
ACCELERATED
INFERENCE
DISTRIBUTED
TRAINING
DYNAMIC 

NEURAL 

NETWORKS
EAGER &
GRAPH-BASED
EXECUTION
WHAT IS PYTORCH?
P Y T O R C H
R E S E A R C H
P R O T O T Y P I N G
P R O D U C T I O N
D E P L O Y M E N T
+
C O R E P R I N C I P L E S
BUILDING
FOR SCALE
DEVELOPER
EFFICIENCY
DEVELOPER EFFICIENCY
ENABLING A HIGH VELOCITY OF MODEL
ITERATION AND INNOVATION
`
C L E A N A P I S
`
T O R C H S C R I P T
Models are Python TorchScript programs,
an optimizable subset of Python
+ Same “models are programs” idea
+ Production deployment
+ No Python dependency
+ Compilation for performance
optimization
class RNN(nn.Module):
  def __init__(self, W_h, U_h, W_y, b_h, b_y):
    super(RNN, self).__init__()
    self.W_h = nn.Parameter(W_h)
    self.U_h = nn.Parameter(U_h)
    self.W_y = nn.Parameter(W_y)
    self.b_h = nn.Parameter(b_h)
    self.b_y = nn.Parameter(b_y)
  def forward(self, x, h):
    y = []
    for t in range(x.size(0)):
      h = torch.tanh(x[t] @ self.W_h + h @ self.U_h + self.b_h)
      y += [torch.tanh(h @ self.W_y + self.b_y)]
      if t % 10 == 0:
        print("stats: ", h.mean(), h.var())
    return torch.stack(y), h


# one annotation!
script_rnn = torch.jit.script(RNN(W_h, U_h, W_y, b_h, b_y))
`
T O R C H S C R I P T
Models are Python TorchScript programs,
an optimizable subset of Python
+ Same “models are programs” idea
+ Prod deployment
+ No Python dependency
+ Optimizable (incl. codegen!)
`
T E N S O R B O A R D
~1,230C O N T R I B U T O R S
50%+Y O Y G R O W T H
23KP Y T O R C H F O R U M U S E R S
GROW TH IN ARXIV MENTIONS IN RESEARCH PAPERS
0
100
200
300
400
500
Jan
17
Feb
17
M
ar17
Apr17
M
ay17
Jun
17
Jul17
Aug17
Sep
17
Jan
18
Feb
18
M
ar18
Apr18
M
ay18
Jun
18
Jul18
Aug18
Sep
18
Jan
19
Feb
19
M
ar19
Apr19
M
ay19
Jun
19
Jul19
F R A M E W O R K S
D Y N A M I C V S . S T A T I C
Declarative
Toolkits
COMPUTATIONGRAPH
DECLARATIVETOOLKITS
Declare and compile a model
Repeatedly execute the model in a VM
TOOLKIT VM
PYTHON SCRIPT
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
import tensorflow as tf

import numpy as np
trX = np.linspace(-1, 1, 101)

trY = 2 * trX + np.random.randn(*trX.shape) * 0.33
X = tf.placeholder("float")

Y = tf.placeholder("float")
def model(X, w):
return tf.multiply(X, w)
w = tf.Variable(0.0, name="weights")

y_model = model(X, w)
cost = tf.square(Y - y_model)
train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
with tf.Session() as sess:
tf.global_variables_initializer().run()
for i in range(100):
for (x, y) in zip(trX, trY):
sess.run(train_op, feed_dict={X: x, Y: y})
print(sess.run(w))
DECLARATIVETOOLKITS
Computation Graph
• Declare a
computation
• Placeholder
variables
• Compile it
• Run it in a Session
import tensorflow as tf

import numpy as np
trX = np.linspace(-1, 1, 101)

trY = 2 * trX + np.random.randn(*trX.shape) * 0.33
X = tf.placeholder("float")

Y = tf.placeholder("float")
def model(X, w):
return tf.multiply(X, w)
w = tf.Variable(0.0, name="weights")

y_model = model(X, w)
cost = tf.square(Y - y_model)
train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
with tf.Session() as sess:
tf.global_variables_initializer().run()
for i in range(100):
for (x, y) in zip(trX, trY):
sess.run(train_op, feed_dict={X: x, Y: y})
print(sess.run(w))
X = tf.placeholder("float")

Y = tf.placeholder("float")
DECLARATIVETOOLKITS
Computation Graph
• Declare a
computation
• Placeholder
variables
• Compile it
• Run it in a Session
import tensorflow as tf

import numpy as np
trX = np.linspace(-1, 1, 101)

trY = 2 * trX + np.random.randn(*trX.shape) * 0.33
X = tf.placeholder("float")

Y = tf.placeholder("float")
def model(X, w):
return tf.multiply(X, w)
w = tf.Variable(0.0, name="weights")

y_model = model(X, w)
cost = tf.square(Y - y_model)
train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
with tf.Session() as sess:
tf.global_variables_initializer().run()
for i in range(100):
for (x, y) in zip(trX, trY):
sess.run(train_op, feed_dict={X: x, Y: y})
print(sess.run(w))
Model definition
def model(X, w):
return tf.multiply(X, w)
w = tf.Variable(0.0, name="weights")

y_model = model(X, w)
cost = tf.square(Y - y_model)
train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
DECLARATIVETOOLKITS
Computation Graph
• Declare a
computation
• Placeholder
variables
• Compile it
• Run it in a Session
import tensorflow as tf

import numpy as np
trX = np.linspace(-1, 1, 101)

trY = 2 * trX + np.random.randn(*trX.shape) * 0.33
X = tf.placeholder("float")

Y = tf.placeholder("float")
def model(X, w):
return tf.multiply(X, w)
w = tf.Variable(0.0, name="weights")

y_model = model(X, w)
cost = tf.square(Y - y_model)
train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
with tf.Session() as sess:
tf.global_variables_initializer().run()
for i in range(100):
for (x, y) in zip(trX, trY):
sess.run(train_op, feed_dict={X: x, Y: y})
print(sess.run(w))
sess.run(train_op, feed_dict={X: x, Y: y})
print(sess.run(w))
A separate, Turing complete, virtual machine.
for i in range(100):
for (x, y) in zip(trX, trY):
DECLARATIVETOOLKITS
Computation Graph
• Declare a
computation
• Placeholder
variables
• Compile it
• Run it in a Session
Imperative Toolkits
DEFINE-BY-RUN
IMPERATIVETOOLKITS
Run a series of computation
Implicitly defining the model as execution
goes
PYTHON NATIVE RUNTIME
PYTHON INSTRUCTIONS
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
RELU
CONNV2D
BATCHNORM
Imperative Toolkits
import torch

from torch.autograd import Variable
trX = torch.linspace(-1, 1, 101)

trY = 2 * trX + torch.random(*trX.size()) * 0.33
w = Variable(trX.new([0.0]), requires_grad=True)
for i in range(100):
for (x, y) in zip(trX, trY):
X = Variable(x)
Y = Variable(y)
print(X)
print(Y)
y_model = X * w.expand_as(X)
cost = (Y - y_model) * 2
Cost.backward(torch.ones(*cost.size()))
w.data = w.data + 0.01 * w.grad.data
print(w)
• Define a model by
execution
• No separate
compilation stage
• No separate
execution engine
import torch

from torch.autograd import Variable
trX = torch.linspace(-1, 1, 101)

trY = 2 * trX + torch.random(*trX.size()) * 0.33
w = Variable(trX.new([0.0]), requires_grad=True)
for i in range(100):
for (x, y) in zip(trX, trY):
X = Variable(x)
Y = Variable(y)
print(X)
print(Y)
y_model = X * w.expand_as(X)
cost = (Y - y_model) * 2
Cost.backward(torch.ones(*cost.size()))
w.data = w.data + 0.01 * w.grad.data
print(w)
Imperative Toolkits
Model constructed and values computed as we define it.
• Define a model by
execution
• No separate
compilation stage
• No separate
execution engine
P Y T O R C H
F O R E M B E D D E D
S T A T E O F T H E S T A T E
H O W D O I R U N P Y T O R C H M O D E L S O N D E V I C E ?
H O W D O I R U N P Y T O R C H M O D E L S O N D E V I C E ?
E X P O R T O N N X F O R M A T T E D M O D E L S
H O W D O I R U N P Y T O R C H M O D E L S O N D E V I C E ?
E X P O R T O N N X F O R M A T T E D M O D E L S
P Y T O R C H M O B I L E
P Y T O R C H
O N N X S U P P O R T
O N N X E c o s y s t e m
A R C H I T E C T U R E 

A N D F L O W
JIT
Tracer
and
Torchscript
ONNX

Exporter
Optimizer
Torch IR to
ONNX IR
Translator
Torch IR
ONNX
torch.onnx

.export()
PyTorch Model
Sample Input
ONNX Graph
Partners
P Y T O R C H
M O B I L E
P R E V I E W
R E L E A S E
W H A T I S   P Y T O R C H   M O B I L E ?
W H A T I S   P Y T O R C H   M O B I L E ?
I T ’ S P Y T O R C H
W H A T I S   P Y T O R C H   M O B I L E ?
I T ’ S P Y T O R C H
F O R M O B I L E 😃
W H A T I S   P Y T O R C H   M O B I L E ?
I T ’ S P Y T O R C H
F O R M O B I L E
B U T N O P Y T H O N
😃
W H A T C A N I T R U N ?
A N Y T O R C H S C R I P T M O D E L .
W H A T C A N I T R U N ?
A N Y T O R C H S C R I P T M O D E L .
L O O P S ? Y E S
W H A T C A N I T R U N ?
A N Y T O R C H S C R I P T M O D E L .
L O O P S ?
F U N C T I O N S ?
Y E S
Y E S
W H A T C A N I T R U N ?
A N Y T O R C H S C R I P T M O D E L .
L O O P S ?
F U N C T I O N S ?
T U P L E S ?
Y E S
Y E S 

Y E S
W H A T C A N I T R U N ?
A N Y T O R C H S C R I P T M O D E L .
L O O P S ?
F U N C T I O N S ?
T U P L E S ?
N A M E D T U P L E ?
Y E S
Y E S 

Y E S
Y E S
ANDROID - MAVEN iOS - COCOAPODS
MODEL OPTIMIZATION (OPTIONAL )
PY TORCH MOBILE
• No separate runtime to export
P Y T O R C H 1 . 3
AUTHOR A MODEL IN PYTORCH
implementation
'org.pytorch:pytorch_
android:1.3.0'
pod ‘LibTorch’
qmodel = quantization.convert(my_mobile_model)
torch.jit.script(qmodel).save(“my_mobile_model.pt")
C O M I N G S O O N
• Build level optimization and selective compilation
• Whole program optimization with link time optimization
End-to-end workflows for mobile in iOS 

and Android:
EXPERIMENTAL
QUANTIZATION
P Y T O R C H 1 . 3
model = ResNet50()
model.load_state_dict(torch.load("model.pt"))
qmodel = quantization.prepare(
model, {"": quantization.default_qconfig})
qmodel.eval()
for batch, target in data_loader:
model(batch)
qmodel = quantization.convert(qmodel)
4XL E S S M E M O R Y 

U S A G E
2-4XS P E E D U P S I N 

C O M P U T E
EXPERIMENTAL
• Neural networks inference is expensive
• IoT and mobile devices have limited resources
• Quantizing models enables efficient inference at scale
H O W D O I U S E I T ?
H O W D O I U S E I T ?
TorchScript
A static, high-performance subset of Python.
1. Prototype your model with PyTorch
2. Control flow is preserved
3. First-class support for lists, dicts, etc.
import torch
class MyModule(torch.nn.Module):
    def __init__(self, N, M, state: List[Tensor]):
        super(MyModule, self).__init__()
        self.weight = torch.nn.Parameter(torch.rand(N, M))
        self.state = state
    def forward(self, input):
        self.state.append(input)
        if input.sum() > 0:
            output = self.weight.mv(input)
        else:
            output = self.weight + input
        return output
# Compile the model code to a static representation
my_module = MyModule(3, 4, [torch.rand(3, 4)])
my_script_module = torch.jit.script(my_module)
# Save the compiled code and model data 
# so it can be loaded elsewhere
my_script_module.save("my_script_module.pt")
H O W D O I U S E I T ?
TorchScript
A static, high-performance subset of Python.
1. Prototype your model with PyTorch
2. Control flow is preserved
3. First-class support for lists, dicts, etc.
import torch
class MyModule(torch.nn.Module):
    def __init__(self, N, M, state: List[Tensor]):
        super(MyModule, self).__init__()
        self.weight = torch.nn.Parameter(torch.rand(N, M))
        self.state = state
    def forward(self, input):
        self.state.append(input)
        if input.sum() > 0:
            output = self.weight.mv(input)
        else:
            output = self.weight + input
        return output
# Compile the model code to a static representation
my_module = MyModule(3, 4, [torch.rand(3, 4)])
my_script_module = torch.jit.script(my_module)
# Save the compiled code and model data 
# so it can be loaded elsewhere
my_script_module.save("my_script_module.pt")
H O W D O I U S E I T ?
# Compile the model code to a static representation
my_module = MyModule(3, 4, [torch.rand(3, 4)])
my_script_module = torch.jit.script(my_module)
# Save the compiled code and model data 
# so it can be loaded elsewhere
my_script_module.save("my_script_module.pt")
H O W D O I U S E I T ?
ANDROID iOS
implementation
  'org.pytorch:pytorch_android:1.3.0'
pod 'LibTorch'
H O W D O E S I T W O R K ?
ANDROID iOS
H O W D O E S I T W O R K ?
ANDROID iOS
https://github.com/pytorch/android-demo-app https://github.com/pytorch/ios-demo-app
W H A T ' S H E R E T O D A Y ?
Full TorchScript support.
Pre-built binary releases in JCenter and CocoaPods.
Java bindings.
All forward CPU operators.
Some optimized float operators (based on Caffe2Go).
Some optimized quantized operators (based on QNNPACK w/ XNNPACK WIP).
W H A T ' S C O M I N G U P ?
Faster.
Smaller.
Customized builds.
Obj-C/Swift API?
Kotlin wrapper?
GPU support??
Accelerator support??
T H A N K Y O U

Weitere ähnliche Inhalte

Was ist angesagt?

Feature pyramid networks for object detection
Feature pyramid networks for object detection Feature pyramid networks for object detection
Feature pyramid networks for object detection
heedaeKwon
 

Was ist angesagt? (20)

Kashiwa.R#1 画像解析とパターン認識における R の利用
Kashiwa.R#1 画像解析とパターン認識における R の利用Kashiwa.R#1 画像解析とパターン認識における R の利用
Kashiwa.R#1 画像解析とパターン認識における R の利用
 
3D CNNによる人物行動認識の動向
3D CNNによる人物行動認識の動向3D CNNによる人物行動認識の動向
3D CNNによる人物行動認識の動向
 
Transformerを用いたAutoEncoderの設計と実験
Transformerを用いたAutoEncoderの設計と実験Transformerを用いたAutoEncoderの設計と実験
Transformerを用いたAutoEncoderの設計と実験
 
Digit recognition using mnist database
Digit recognition using mnist databaseDigit recognition using mnist database
Digit recognition using mnist database
 
モデルアーキテクチャ観点からの高速化2019
モデルアーキテクチャ観点からの高速化2019モデルアーキテクチャ観点からの高速化2019
モデルアーキテクチャ観点からの高速化2019
 
Feature pyramid networks for object detection
Feature pyramid networks for object detection Feature pyramid networks for object detection
Feature pyramid networks for object detection
 
TensorFlow and Keras: An Overview
TensorFlow and Keras: An OverviewTensorFlow and Keras: An Overview
TensorFlow and Keras: An Overview
 
Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)
 
Deep Learning - CNN and RNN
Deep Learning - CNN and RNNDeep Learning - CNN and RNN
Deep Learning - CNN and RNN
 
Multimodal Learning with Severely Missing Modality.pptx
Multimodal Learning with Severely Missing Modality.pptxMultimodal Learning with Severely Missing Modality.pptx
Multimodal Learning with Severely Missing Modality.pptx
 
Deep learning with Keras
Deep learning with KerasDeep learning with Keras
Deep learning with Keras
 
Matlantisで実現する不均一系理論触媒科学3.0: Ru/La0.5Ce0.5O1.75-xにおける強い金属・担体相互作用の解明と展望_PFCCウェ...
Matlantisで実現する不均一系理論触媒科学3.0: Ru/La0.5Ce0.5O1.75-xにおける強い金属・担体相互作用の解明と展望_PFCCウェ...Matlantisで実現する不均一系理論触媒科学3.0: Ru/La0.5Ce0.5O1.75-xにおける強い金属・担体相互作用の解明と展望_PFCCウェ...
Matlantisで実現する不均一系理論触媒科学3.0: Ru/La0.5Ce0.5O1.75-xにおける強い金属・担体相互作用の解明と展望_PFCCウェ...
 
三次元点群を取り扱うニューラルネットワークのサーベイ
三次元点群を取り扱うニューラルネットワークのサーベイ三次元点群を取り扱うニューラルネットワークのサーベイ
三次元点群を取り扱うニューラルネットワークのサーベイ
 
Spiking neural network: an introduction I
Spiking neural network: an introduction ISpiking neural network: an introduction I
Spiking neural network: an introduction I
 
Convolution Neural Network (CNN)
Convolution Neural Network (CNN)Convolution Neural Network (CNN)
Convolution Neural Network (CNN)
 
Introduction to Deep Learning
Introduction to Deep LearningIntroduction to Deep Learning
Introduction to Deep Learning
 
Hardware Acceleration for Machine Learning
Hardware Acceleration for Machine LearningHardware Acceleration for Machine Learning
Hardware Acceleration for Machine Learning
 
multiple object tracking using particle filter
multiple object tracking using particle filtermultiple object tracking using particle filter
multiple object tracking using particle filter
 
Mask R-CNN
Mask R-CNNMask R-CNN
Mask R-CNN
 
Image classification using cnn
Image classification using cnnImage classification using cnn
Image classification using cnn
 

Ähnlich wie "PyTorch Deep Learning Framework: Status and Directions," a Presentation from Facebook

Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimization
g3_nittala
 

Ähnlich wie "PyTorch Deep Learning Framework: Status and Directions," a Presentation from Facebook (20)

Soumith Chintala - Increasing the Impact of AI Through Better Software
Soumith Chintala - Increasing the Impact of AI Through Better SoftwareSoumith Chintala - Increasing the Impact of AI Through Better Software
Soumith Chintala - Increasing the Impact of AI Through Better Software
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler Development
 
Type Systems on the example of TypeScript
Type Systems on the example of TypeScriptType Systems on the example of TypeScript
Type Systems on the example of TypeScript
 
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
 
Scaling Up AI Research to Production with PyTorch and MLFlow
Scaling Up AI Research to Production with PyTorch and MLFlowScaling Up AI Research to Production with PyTorch and MLFlow
Scaling Up AI Research to Production with PyTorch and MLFlow
 
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
 
TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習
 
Writing (Meteor) Code With Style
Writing (Meteor) Code With StyleWriting (Meteor) Code With Style
Writing (Meteor) Code With Style
 
Model Serving via Pulsar Functions
Model Serving via Pulsar FunctionsModel Serving via Pulsar Functions
Model Serving via Pulsar Functions
 
Profiling PyTorch for Efficiency & Sustainability
Profiling PyTorch for Efficiency & SustainabilityProfiling PyTorch for Efficiency & Sustainability
Profiling PyTorch for Efficiency & Sustainability
 
AAD UNIT 2.pptx
AAD UNIT 2.pptxAAD UNIT 2.pptx
AAD UNIT 2.pptx
 
AAD.pptx
AAD.pptxAAD.pptx
AAD.pptx
 
Ember js meetup treviso liquid-fire
Ember js meetup treviso liquid-fireEmber js meetup treviso liquid-fire
Ember js meetup treviso liquid-fire
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limiters
 
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’a
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’aTen Typ tak ma - O systemach typów na przykładzie TypeScript’a
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’a
 
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimization
 
機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編
 
Hardware Description Languages .pptx
Hardware Description Languages .pptxHardware Description Languages .pptx
Hardware Description Languages .pptx
 
Introduction to Java Profiling
Introduction to Java ProfilingIntroduction to Java Profiling
Introduction to Java Profiling
 

Mehr von Edge AI and Vision Alliance

“Learning Compact DNN Models for Embedded Vision,” a Presentation from the Un...
“Learning Compact DNN Models for Embedded Vision,” a Presentation from the Un...“Learning Compact DNN Models for Embedded Vision,” a Presentation from the Un...
“Learning Compact DNN Models for Embedded Vision,” a Presentation from the Un...
Edge AI and Vision Alliance
 
“Selecting Tools for Developing, Monitoring and Maintaining ML Models,” a Pre...
“Selecting Tools for Developing, Monitoring and Maintaining ML Models,” a Pre...“Selecting Tools for Developing, Monitoring and Maintaining ML Models,” a Pre...
“Selecting Tools for Developing, Monitoring and Maintaining ML Models,” a Pre...
Edge AI and Vision Alliance
 
“Vision-language Representations for Robotics,” a Presentation from the Unive...
“Vision-language Representations for Robotics,” a Presentation from the Unive...“Vision-language Representations for Robotics,” a Presentation from the Unive...
“Vision-language Representations for Robotics,” a Presentation from the Unive...
Edge AI and Vision Alliance
 
“Computer Vision in Sports: Scalable Solutions for Downmarkets,” a Presentati...
“Computer Vision in Sports: Scalable Solutions for Downmarkets,” a Presentati...“Computer Vision in Sports: Scalable Solutions for Downmarkets,” a Presentati...
“Computer Vision in Sports: Scalable Solutions for Downmarkets,” a Presentati...
Edge AI and Vision Alliance
 
“AI Start-ups: The Perils of Fishing for Whales (War Stories from the Entrepr...
“AI Start-ups: The Perils of Fishing for Whales (War Stories from the Entrepr...“AI Start-ups: The Perils of Fishing for Whales (War Stories from the Entrepr...
“AI Start-ups: The Perils of Fishing for Whales (War Stories from the Entrepr...
Edge AI and Vision Alliance
 
“Bias in Computer Vision—It’s Bigger Than Facial Recognition!,” a Presentatio...
“Bias in Computer Vision—It’s Bigger Than Facial Recognition!,” a Presentatio...“Bias in Computer Vision—It’s Bigger Than Facial Recognition!,” a Presentatio...
“Bias in Computer Vision—It’s Bigger Than Facial Recognition!,” a Presentatio...
Edge AI and Vision Alliance
 
“Updating the Edge ML Development Process,” a Presentation from Samsara
“Updating the Edge ML Development Process,” a Presentation from Samsara“Updating the Edge ML Development Process,” a Presentation from Samsara
“Updating the Edge ML Development Process,” a Presentation from Samsara
Edge AI and Vision Alliance
 
“Developing an Embedded Vision AI-powered Fitness System,” a Presentation fro...
“Developing an Embedded Vision AI-powered Fitness System,” a Presentation fro...“Developing an Embedded Vision AI-powered Fitness System,” a Presentation fro...
“Developing an Embedded Vision AI-powered Fitness System,” a Presentation fro...
Edge AI and Vision Alliance
 

Mehr von Edge AI and Vision Alliance (20)

“Learning Compact DNN Models for Embedded Vision,” a Presentation from the Un...
“Learning Compact DNN Models for Embedded Vision,” a Presentation from the Un...“Learning Compact DNN Models for Embedded Vision,” a Presentation from the Un...
“Learning Compact DNN Models for Embedded Vision,” a Presentation from the Un...
 
“Introduction to Computer Vision with CNNs,” a Presentation from Mohammad Hag...
“Introduction to Computer Vision with CNNs,” a Presentation from Mohammad Hag...“Introduction to Computer Vision with CNNs,” a Presentation from Mohammad Hag...
“Introduction to Computer Vision with CNNs,” a Presentation from Mohammad Hag...
 
“Selecting Tools for Developing, Monitoring and Maintaining ML Models,” a Pre...
“Selecting Tools for Developing, Monitoring and Maintaining ML Models,” a Pre...“Selecting Tools for Developing, Monitoring and Maintaining ML Models,” a Pre...
“Selecting Tools for Developing, Monitoring and Maintaining ML Models,” a Pre...
 
“Building Accelerated GStreamer Applications for Video and Audio AI,” a Prese...
“Building Accelerated GStreamer Applications for Video and Audio AI,” a Prese...“Building Accelerated GStreamer Applications for Video and Audio AI,” a Prese...
“Building Accelerated GStreamer Applications for Video and Audio AI,” a Prese...
 
“Understanding, Selecting and Optimizing Object Detectors for Edge Applicatio...
“Understanding, Selecting and Optimizing Object Detectors for Edge Applicatio...“Understanding, Selecting and Optimizing Object Detectors for Edge Applicatio...
“Understanding, Selecting and Optimizing Object Detectors for Edge Applicatio...
 
“Introduction to Modern LiDAR for Machine Perception,” a Presentation from th...
“Introduction to Modern LiDAR for Machine Perception,” a Presentation from th...“Introduction to Modern LiDAR for Machine Perception,” a Presentation from th...
“Introduction to Modern LiDAR for Machine Perception,” a Presentation from th...
 
“Vision-language Representations for Robotics,” a Presentation from the Unive...
“Vision-language Representations for Robotics,” a Presentation from the Unive...“Vision-language Representations for Robotics,” a Presentation from the Unive...
“Vision-language Representations for Robotics,” a Presentation from the Unive...
 
“ADAS and AV Sensors: What’s Winning and Why?,” a Presentation from TechInsights
“ADAS and AV Sensors: What’s Winning and Why?,” a Presentation from TechInsights“ADAS and AV Sensors: What’s Winning and Why?,” a Presentation from TechInsights
“ADAS and AV Sensors: What’s Winning and Why?,” a Presentation from TechInsights
 
“Computer Vision in Sports: Scalable Solutions for Downmarkets,” a Presentati...
“Computer Vision in Sports: Scalable Solutions for Downmarkets,” a Presentati...“Computer Vision in Sports: Scalable Solutions for Downmarkets,” a Presentati...
“Computer Vision in Sports: Scalable Solutions for Downmarkets,” a Presentati...
 
“Detecting Data Drift in Image Classification Neural Networks,” a Presentatio...
“Detecting Data Drift in Image Classification Neural Networks,” a Presentatio...“Detecting Data Drift in Image Classification Neural Networks,” a Presentatio...
“Detecting Data Drift in Image Classification Neural Networks,” a Presentatio...
 
“Deep Neural Network Training: Diagnosing Problems and Implementing Solutions...
“Deep Neural Network Training: Diagnosing Problems and Implementing Solutions...“Deep Neural Network Training: Diagnosing Problems and Implementing Solutions...
“Deep Neural Network Training: Diagnosing Problems and Implementing Solutions...
 
“AI Start-ups: The Perils of Fishing for Whales (War Stories from the Entrepr...
“AI Start-ups: The Perils of Fishing for Whales (War Stories from the Entrepr...“AI Start-ups: The Perils of Fishing for Whales (War Stories from the Entrepr...
“AI Start-ups: The Perils of Fishing for Whales (War Stories from the Entrepr...
 
“A Computer Vision System for Autonomous Satellite Maneuvering,” a Presentati...
“A Computer Vision System for Autonomous Satellite Maneuvering,” a Presentati...“A Computer Vision System for Autonomous Satellite Maneuvering,” a Presentati...
“A Computer Vision System for Autonomous Satellite Maneuvering,” a Presentati...
 
“Bias in Computer Vision—It’s Bigger Than Facial Recognition!,” a Presentatio...
“Bias in Computer Vision—It’s Bigger Than Facial Recognition!,” a Presentatio...“Bias in Computer Vision—It’s Bigger Than Facial Recognition!,” a Presentatio...
“Bias in Computer Vision—It’s Bigger Than Facial Recognition!,” a Presentatio...
 
“Sensor Fusion Techniques for Accurate Perception of Objects in the Environme...
“Sensor Fusion Techniques for Accurate Perception of Objects in the Environme...“Sensor Fusion Techniques for Accurate Perception of Objects in the Environme...
“Sensor Fusion Techniques for Accurate Perception of Objects in the Environme...
 
“Updating the Edge ML Development Process,” a Presentation from Samsara
“Updating the Edge ML Development Process,” a Presentation from Samsara“Updating the Edge ML Development Process,” a Presentation from Samsara
“Updating the Edge ML Development Process,” a Presentation from Samsara
 
“Combating Bias in Production Computer Vision Systems,” a Presentation from R...
“Combating Bias in Production Computer Vision Systems,” a Presentation from R...“Combating Bias in Production Computer Vision Systems,” a Presentation from R...
“Combating Bias in Production Computer Vision Systems,” a Presentation from R...
 
“Developing an Embedded Vision AI-powered Fitness System,” a Presentation fro...
“Developing an Embedded Vision AI-powered Fitness System,” a Presentation fro...“Developing an Embedded Vision AI-powered Fitness System,” a Presentation fro...
“Developing an Embedded Vision AI-powered Fitness System,” a Presentation fro...
 
“Navigating the Evolving Venture Capital Landscape for Edge AI Start-ups,” a ...
“Navigating the Evolving Venture Capital Landscape for Edge AI Start-ups,” a ...“Navigating the Evolving Venture Capital Landscape for Edge AI Start-ups,” a ...
“Navigating the Evolving Venture Capital Landscape for Edge AI Start-ups,” a ...
 
“Advanced Presence Sensing: What It Means for the Smart Home,” a Presentation...
“Advanced Presence Sensing: What It Means for the Smart Home,” a Presentation...“Advanced Presence Sensing: What It Means for the Smart Home,” a Presentation...
“Advanced Presence Sensing: What It Means for the Smart Home,” a Presentation...
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 

"PyTorch Deep Learning Framework: Status and Directions," a Presentation from Facebook

  • 1. J O S E P H S P I S A K P R O D U C T M A N A G E R P Y T O R C H | O N D E V I C E
  • 2. OVERVIEW AND INTEGRATION PYTORCH MOBILE STATE OF THE STATE ON DEVICE DYNAMIC VS. STATIC FRAMEWORKS PRINCIPLES, MAKEUP, .. OVERVIEW
  • 6. P Y T O R C H O V E R V I E W
  • 8. P Y T O R C H R E S E A R C H P R O T O T Y P I N G P R O D U C T I O N D E P L O Y M E N T +
  • 9. C O R E P R I N C I P L E S BUILDING FOR SCALE DEVELOPER EFFICIENCY
  • 10. DEVELOPER EFFICIENCY ENABLING A HIGH VELOCITY OF MODEL ITERATION AND INNOVATION
  • 11. ` C L E A N A P I S
  • 12. ` T O R C H S C R I P T Models are Python TorchScript programs, an optimizable subset of Python + Same “models are programs” idea + Production deployment + No Python dependency + Compilation for performance optimization class RNN(nn.Module):   def __init__(self, W_h, U_h, W_y, b_h, b_y):     super(RNN, self).__init__()     self.W_h = nn.Parameter(W_h)     self.U_h = nn.Parameter(U_h)     self.W_y = nn.Parameter(W_y)     self.b_h = nn.Parameter(b_h)     self.b_y = nn.Parameter(b_y)   def forward(self, x, h):     y = []     for t in range(x.size(0)):       h = torch.tanh(x[t] @ self.W_h + h @ self.U_h + self.b_h)       y += [torch.tanh(h @ self.W_y + self.b_y)]       if t % 10 == 0:         print("stats: ", h.mean(), h.var())     return torch.stack(y), h 
 # one annotation! script_rnn = torch.jit.script(RNN(W_h, U_h, W_y, b_h, b_y))
  • 13. ` T O R C H S C R I P T Models are Python TorchScript programs, an optimizable subset of Python + Same “models are programs” idea + Prod deployment + No Python dependency + Optimizable (incl. codegen!)
  • 14. ` T E N S O R B O A R D
  • 15. ~1,230C O N T R I B U T O R S 50%+Y O Y G R O W T H 23KP Y T O R C H F O R U M U S E R S
  • 16. GROW TH IN ARXIV MENTIONS IN RESEARCH PAPERS 0 100 200 300 400 500 Jan 17 Feb 17 M ar17 Apr17 M ay17 Jun 17 Jul17 Aug17 Sep 17 Jan 18 Feb 18 M ar18 Apr18 M ay18 Jun 18 Jul18 Aug18 Sep 18 Jan 19 Feb 19 M ar19 Apr19 M ay19 Jun 19 Jul19
  • 17. F R A M E W O R K S D Y N A M I C V S . S T A T I C
  • 19. DECLARATIVETOOLKITS Declare and compile a model Repeatedly execute the model in a VM TOOLKIT VM PYTHON SCRIPT RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM
  • 20. import tensorflow as tf
 import numpy as np trX = np.linspace(-1, 1, 101)
 trY = 2 * trX + np.random.randn(*trX.shape) * 0.33 X = tf.placeholder("float")
 Y = tf.placeholder("float") def model(X, w): return tf.multiply(X, w) w = tf.Variable(0.0, name="weights")
 y_model = model(X, w) cost = tf.square(Y - y_model) train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost) with tf.Session() as sess: tf.global_variables_initializer().run() for i in range(100): for (x, y) in zip(trX, trY): sess.run(train_op, feed_dict={X: x, Y: y}) print(sess.run(w)) DECLARATIVETOOLKITS Computation Graph • Declare a computation • Placeholder variables • Compile it • Run it in a Session
  • 21. import tensorflow as tf
 import numpy as np trX = np.linspace(-1, 1, 101)
 trY = 2 * trX + np.random.randn(*trX.shape) * 0.33 X = tf.placeholder("float")
 Y = tf.placeholder("float") def model(X, w): return tf.multiply(X, w) w = tf.Variable(0.0, name="weights")
 y_model = model(X, w) cost = tf.square(Y - y_model) train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost) with tf.Session() as sess: tf.global_variables_initializer().run() for i in range(100): for (x, y) in zip(trX, trY): sess.run(train_op, feed_dict={X: x, Y: y}) print(sess.run(w)) X = tf.placeholder("float")
 Y = tf.placeholder("float") DECLARATIVETOOLKITS Computation Graph • Declare a computation • Placeholder variables • Compile it • Run it in a Session
  • 22. import tensorflow as tf
 import numpy as np trX = np.linspace(-1, 1, 101)
 trY = 2 * trX + np.random.randn(*trX.shape) * 0.33 X = tf.placeholder("float")
 Y = tf.placeholder("float") def model(X, w): return tf.multiply(X, w) w = tf.Variable(0.0, name="weights")
 y_model = model(X, w) cost = tf.square(Y - y_model) train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost) with tf.Session() as sess: tf.global_variables_initializer().run() for i in range(100): for (x, y) in zip(trX, trY): sess.run(train_op, feed_dict={X: x, Y: y}) print(sess.run(w)) Model definition def model(X, w): return tf.multiply(X, w) w = tf.Variable(0.0, name="weights")
 y_model = model(X, w) cost = tf.square(Y - y_model) train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost) DECLARATIVETOOLKITS Computation Graph • Declare a computation • Placeholder variables • Compile it • Run it in a Session
  • 23. import tensorflow as tf
 import numpy as np trX = np.linspace(-1, 1, 101)
 trY = 2 * trX + np.random.randn(*trX.shape) * 0.33 X = tf.placeholder("float")
 Y = tf.placeholder("float") def model(X, w): return tf.multiply(X, w) w = tf.Variable(0.0, name="weights")
 y_model = model(X, w) cost = tf.square(Y - y_model) train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost) with tf.Session() as sess: tf.global_variables_initializer().run() for i in range(100): for (x, y) in zip(trX, trY): sess.run(train_op, feed_dict={X: x, Y: y}) print(sess.run(w)) sess.run(train_op, feed_dict={X: x, Y: y}) print(sess.run(w)) A separate, Turing complete, virtual machine. for i in range(100): for (x, y) in zip(trX, trY): DECLARATIVETOOLKITS Computation Graph • Declare a computation • Placeholder variables • Compile it • Run it in a Session
  • 25. IMPERATIVETOOLKITS Run a series of computation Implicitly defining the model as execution goes PYTHON NATIVE RUNTIME PYTHON INSTRUCTIONS RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM RELU CONNV2D BATCHNORM
  • 26. Imperative Toolkits import torch
 from torch.autograd import Variable trX = torch.linspace(-1, 1, 101)
 trY = 2 * trX + torch.random(*trX.size()) * 0.33 w = Variable(trX.new([0.0]), requires_grad=True) for i in range(100): for (x, y) in zip(trX, trY): X = Variable(x) Y = Variable(y) print(X) print(Y) y_model = X * w.expand_as(X) cost = (Y - y_model) * 2 Cost.backward(torch.ones(*cost.size())) w.data = w.data + 0.01 * w.grad.data print(w) • Define a model by execution • No separate compilation stage • No separate execution engine
  • 27. import torch
 from torch.autograd import Variable trX = torch.linspace(-1, 1, 101)
 trY = 2 * trX + torch.random(*trX.size()) * 0.33 w = Variable(trX.new([0.0]), requires_grad=True) for i in range(100): for (x, y) in zip(trX, trY): X = Variable(x) Y = Variable(y) print(X) print(Y) y_model = X * w.expand_as(X) cost = (Y - y_model) * 2 Cost.backward(torch.ones(*cost.size())) w.data = w.data + 0.01 * w.grad.data print(w) Imperative Toolkits Model constructed and values computed as we define it. • Define a model by execution • No separate compilation stage • No separate execution engine
  • 28. P Y T O R C H F O R E M B E D D E D S T A T E O F T H E S T A T E
  • 29. H O W D O I R U N P Y T O R C H M O D E L S O N D E V I C E ?
  • 30. H O W D O I R U N P Y T O R C H M O D E L S O N D E V I C E ? E X P O R T O N N X F O R M A T T E D M O D E L S
  • 31. H O W D O I R U N P Y T O R C H M O D E L S O N D E V I C E ? E X P O R T O N N X F O R M A T T E D M O D E L S P Y T O R C H M O B I L E
  • 32. P Y T O R C H O N N X S U P P O R T
  • 33. O N N X E c o s y s t e m
  • 34. A R C H I T E C T U R E 
 A N D F L O W JIT Tracer and Torchscript ONNX
 Exporter Optimizer Torch IR to ONNX IR Translator Torch IR ONNX torch.onnx
 .export() PyTorch Model Sample Input ONNX Graph
  • 36. P Y T O R C H M O B I L E P R E V I E W R E L E A S E
  • 37. W H A T I S   P Y T O R C H   M O B I L E ?
  • 38. W H A T I S   P Y T O R C H   M O B I L E ? I T ’ S P Y T O R C H
  • 39. W H A T I S   P Y T O R C H   M O B I L E ? I T ’ S P Y T O R C H F O R M O B I L E 😃
  • 40. W H A T I S   P Y T O R C H   M O B I L E ? I T ’ S P Y T O R C H F O R M O B I L E B U T N O P Y T H O N 😃
  • 41. W H A T C A N I T R U N ? A N Y T O R C H S C R I P T M O D E L .
  • 42. W H A T C A N I T R U N ? A N Y T O R C H S C R I P T M O D E L . L O O P S ? Y E S
  • 43. W H A T C A N I T R U N ? A N Y T O R C H S C R I P T M O D E L . L O O P S ? F U N C T I O N S ? Y E S Y E S
  • 44. W H A T C A N I T R U N ? A N Y T O R C H S C R I P T M O D E L . L O O P S ? F U N C T I O N S ? T U P L E S ? Y E S Y E S 
 Y E S
  • 45. W H A T C A N I T R U N ? A N Y T O R C H S C R I P T M O D E L . L O O P S ? F U N C T I O N S ? T U P L E S ? N A M E D T U P L E ? Y E S Y E S 
 Y E S Y E S
  • 46. ANDROID - MAVEN iOS - COCOAPODS MODEL OPTIMIZATION (OPTIONAL ) PY TORCH MOBILE • No separate runtime to export P Y T O R C H 1 . 3 AUTHOR A MODEL IN PYTORCH implementation 'org.pytorch:pytorch_ android:1.3.0' pod ‘LibTorch’ qmodel = quantization.convert(my_mobile_model) torch.jit.script(qmodel).save(“my_mobile_model.pt") C O M I N G S O O N • Build level optimization and selective compilation • Whole program optimization with link time optimization End-to-end workflows for mobile in iOS 
 and Android: EXPERIMENTAL
  • 47. QUANTIZATION P Y T O R C H 1 . 3 model = ResNet50() model.load_state_dict(torch.load("model.pt")) qmodel = quantization.prepare( model, {"": quantization.default_qconfig}) qmodel.eval() for batch, target in data_loader: model(batch) qmodel = quantization.convert(qmodel) 4XL E S S M E M O R Y 
 U S A G E 2-4XS P E E D U P S I N 
 C O M P U T E EXPERIMENTAL • Neural networks inference is expensive • IoT and mobile devices have limited resources • Quantizing models enables efficient inference at scale
  • 48. H O W D O I U S E I T ?
  • 49. H O W D O I U S E I T ? TorchScript A static, high-performance subset of Python. 1. Prototype your model with PyTorch 2. Control flow is preserved 3. First-class support for lists, dicts, etc. import torch class MyModule(torch.nn.Module):     def __init__(self, N, M, state: List[Tensor]):         super(MyModule, self).__init__()         self.weight = torch.nn.Parameter(torch.rand(N, M))         self.state = state     def forward(self, input):         self.state.append(input)         if input.sum() > 0:             output = self.weight.mv(input)         else:             output = self.weight + input         return output # Compile the model code to a static representation my_module = MyModule(3, 4, [torch.rand(3, 4)]) my_script_module = torch.jit.script(my_module) # Save the compiled code and model data  # so it can be loaded elsewhere my_script_module.save("my_script_module.pt")
  • 50. H O W D O I U S E I T ? TorchScript A static, high-performance subset of Python. 1. Prototype your model with PyTorch 2. Control flow is preserved 3. First-class support for lists, dicts, etc. import torch class MyModule(torch.nn.Module):     def __init__(self, N, M, state: List[Tensor]):         super(MyModule, self).__init__()         self.weight = torch.nn.Parameter(torch.rand(N, M))         self.state = state     def forward(self, input):         self.state.append(input)         if input.sum() > 0:             output = self.weight.mv(input)         else:             output = self.weight + input         return output # Compile the model code to a static representation my_module = MyModule(3, 4, [torch.rand(3, 4)]) my_script_module = torch.jit.script(my_module) # Save the compiled code and model data  # so it can be loaded elsewhere my_script_module.save("my_script_module.pt")
  • 51. H O W D O I U S E I T ? # Compile the model code to a static representation my_module = MyModule(3, 4, [torch.rand(3, 4)]) my_script_module = torch.jit.script(my_module) # Save the compiled code and model data  # so it can be loaded elsewhere my_script_module.save("my_script_module.pt")
  • 52. H O W D O I U S E I T ? ANDROID iOS implementation   'org.pytorch:pytorch_android:1.3.0' pod 'LibTorch'
  • 53. H O W D O E S I T W O R K ? ANDROID iOS
  • 54. H O W D O E S I T W O R K ? ANDROID iOS https://github.com/pytorch/android-demo-app https://github.com/pytorch/ios-demo-app
  • 55. W H A T ' S H E R E T O D A Y ? Full TorchScript support. Pre-built binary releases in JCenter and CocoaPods. Java bindings. All forward CPU operators. Some optimized float operators (based on Caffe2Go). Some optimized quantized operators (based on QNNPACK w/ XNNPACK WIP).
  • 56. W H A T ' S C O M I N G U P ? Faster. Smaller. Customized builds. Obj-C/Swift API? Kotlin wrapper? GPU support?? Accelerator support??
  • 57. T H A N K Y O U