Running Deep Learning in less than 100KB on Microcontrollers Pete - - PowerPoint PPT Presentation

running deep learning in less than 100kb on
SMART_READER_LITE
LIVE PREVIEW

Running Deep Learning in less than 100KB on Microcontrollers Pete - - PowerPoint PPT Presentation

Running Deep Learning in less than 100KB on Microcontrollers Pete Warden Engineer, TensorFlow petewarden@google.com @petewarden Why am I here? 150 Billion Devices! Growing faster than internet users or smaruphones Why ML? Energy! Many


slide-1
SLIDE 1

Running Deep Learning in less than 100KB on Microcontrollers

slide-2
SLIDE 2

Pete Warden

Engineer, TensorFlow petewarden@google.com @petewarden

slide-3
SLIDE 3

Why am I here?

slide-4
SLIDE 4

150 Billion Devices!

Growing faster than internet users or smaruphones

slide-5
SLIDE 5
slide-6
SLIDE 6

Why ML?

slide-7
SLIDE 7

Energy!

Many devices rely on batuery or energy harvesting Transmituing data takes a lot of power, and can’t improve fast enough Capturing and processing data locally very cheap

slide-8
SLIDE 8

Energy!

Most captured data is currently being wasted ML lets us turn it into something actionable

slide-9
SLIDE 9

Demo

slide-10
SLIDE 10

How is this done?

slide-11
SLIDE 11

What are the challenges?

Less than 100KB of RAM and storage Less than 10 million arithmetic ops per second Can’t rely on fmoating point hardware No operating system

slide-12
SLIDE 12

Model Design

We needed a 20KB model Happily common in speech world Learned a lot about quantization Actually just a tiny image CNN on spectrograms

slide-13
SLIDE 13

Model Design

Uses fewer than 400,000 arithmetic operations htups://www.tensorglow.org/tutorials/sequences/a udio_recognition

slide-14
SLIDE 14

Sofuware Design

TensorFlow Lite still > 100KB binary size Depends on Posix and standard C/C++ libraries Uses dynamic memory allocation

slide-15
SLIDE 15

Sofuware Design

But a lot we don’t want to lose from TensorFlow Lite:

  • Existing op implementations
  • Well-documented APIs and fjle format
  • Conversion tooling
slide-16
SLIDE 16

Sofuware Design

But a lot we don’t want to lose from TensorFlow Lite:

  • Existing op implementations
  • Well-documented APIs and fjle format
  • Conversion tooling
slide-17
SLIDE 17

Sofuware Design

Modularized existing code Separated out API defjnitions from implementations Used reference code Added minimal new runtime layer for MCUs

slide-18
SLIDE 18

Sofuware Design

Focused on getuing one end to end example working, rather than going broad poruing whole framework at

  • nce
slide-19
SLIDE 19

What does this mean in practice?

slide-20
SLIDE 20

int32 acc = 0; for (int filter_y = 0; filter_y < filter_height; ++filter_y) { for (int filter_x = 0; filter_x < filter_width; ++filter_x) { const int in_x = in_x_origin + dilation_width_factor * filter_x; const int in_y = in_y_origin + dilation_height_factor * filter_y; // If the location is outside the bounds of the input image, // use zero as a default value. if ((in_x >= 0) && (in_x < input_width) && (in_y >= 0) && (in_y < input_height)) { int32 input_val = input_data[Offset(input_shape, b, in_y, in_x, ic)]; int32 filter_val = filter_data[Offset( filter_shape, 0, filter_y, filter_x, oc)]; acc += (filter_val + filter_offset) * (input_val + input_offset); } } }

slide-21
SLIDE 21

Reference code is imporuant

Most ML operations can be implemented simply Most frameworks only ship with optimized versions Understandable, but makes it very hard to extend or

  • ptimize for other platgorms
slide-22
SLIDE 22

What’s the takeaway?

slide-23
SLIDE 23

There is no killer app

Voice intergaces are the closest Vision, accelerometer, audio sensors ofger a lot Need to connect with the right problems

slide-24
SLIDE 24

Think about your domain

What could you do if your model ran on a 50 cent chip that could be peeled and stuck anywhere, and run forever?

slide-25
SLIDE 25

Get it. Try it.

Code: github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/experimental/micro Docs: tensorglow.org/lite/guide/microcontroller Example: g.co/codelabs/sparkfunTF

slide-26
SLIDE 26

Pete Warden

Engineer, TensorFlow petewarden@google.com @petewarden