Slide 1

Slide 1 text

Building AI units using Rust FOSSASIA SUMMIT 2018 Vigneshwer Dhinakaran | Mozilla TechSpeaker | @dvigneshwer

Slide 2

Slide 2 text

Applications & Algorithms!

Slide 3

Slide 3 text

Computer Vision - Object classification & Tracking - CNN, Selective search, R-CNN, MHT .. - Surveillance, Business usecases etc

Slide 4

Slide 4 text

Chatbots - Text Classification and Resolutions - RNN, LSTM, beam search .. - B2C, products domains!

Slide 5

Slide 5 text

Predictive Maintenance - Anomaly detection - Time-series analysis, Regression techs, Kalman filtering ... - IoT space, Monitoring Industrial machinery

Slide 6

Slide 6 text

Complex Games - Taking real world actions & optimization problems - MDP, Reinforcement learning, dynamic programming - Self driving cars, Trading engines

Slide 7

Slide 7 text

Voice Search - ASR and synthesis - Spectrograms, CTC - Content captioning, Cars/Hands-free interfaces, Home devices

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Building ML Models

Slide 10

Slide 10 text

Building ML Models Data Collection Data Analysis Statistics Development & Training Deployment and monitoring Project Definition Modelling

Slide 11

Slide 11 text

Building an ANN Learning Algorithm Neural Network Neuron Representation Neuron Network Cost Function Back propagation

Slide 12

Slide 12 text

Rust is easy to learn!

Slide 13

Slide 13 text

Snips Uses Rust to Build an Embedded Voice Assistant

Slide 14

Slide 14 text

Speeding up crypto on Wire desktop apps https://medium.com/@wireapp/speeding-up-crypto-on-wire-desktop-apps-3ff37fc98c3f Up to 141× faster

Slide 15

Slide 15 text

Gradual adoption works.

Slide 16

Slide 16 text

2016 -18 For the third year in a row, Rust is stackoverflow's most loved language https://insights.stackoverflow.com/survey/2018/

Slide 17

Slide 17 text

Friends of Rust Organizations running Rust in production. (https://www.rust-lang.org/en-US/friends.html)

Slide 18

Slide 18 text

Why Rust? Freedom from Data Race conditions Strong type system High level iterators More control over memory Tools Ecosystem Welcoming Community

Slide 19

Slide 19 text

Ownership The act, state, or right of possessing something

Slide 20

Slide 20 text

Garbage Collection Heap Memory new Circle(5) new Circle(5) new Circle(5)

Slide 21

Slide 21 text

Referencing Now both bookingService and repairService hold a reference to vehicle

Slide 22

Slide 22 text

Same implementation in Rust Doesn't compile!

Slide 23

Slide 23 text

Ownership ● Rust moves ownership by default ● The owner has the right to destroy the thing it owns ● The memory is freed as soon as the owned variable goes out of it's scope ● Hence vehicle may already be destroyed at the point when it's passed to repair_service ● Rust catches these errors at compile time

Slide 24

Slide 24 text

Borrowing The act, state, or right of possessing something

Slide 25

Slide 25 text

Making it work in Rust Lending things is the key!

Slide 26

Slide 26 text

Borrowing ● A reference is passed without transferring ownership ● One can borrow immutable (&) or mutable (&mut) but not both at the same time ● Shared ownership can be achieved through special pointers with runtime checks

Slide 27

Slide 27 text

Mutability Rules ● All variables are immutable by default ● Only one mutable reference at a time ( But as many immutable &’s as you want ) ● Mutable references block all other access (The &mut must go out of scope before using other &’s )

Slide 28

Slide 28 text

Building an ANN using Rust

Slide 29

Slide 29 text

ANN in Rust Preparing Dataset Algorithm and Arch. Building Model Testing and Productionalizatio

Slide 30

Slide 30 text

Value Addition

Slide 31

Slide 31 text

Value Addition

Slide 32

Slide 32 text

Interesting?

Slide 33

Slide 33 text

Summary

Slide 34

Slide 34 text

When should you use Rust? ● Rewrite modules of your code that are computationally heavy (Complex math optimizations etc) ● For accessing the hardware(ex :- IOT applications, device drivers, GPU’s etc) ● Implementing advance concurrency paradigms

Slide 35

Slide 35 text

What does Rust have to offer? ● Modern C/C++ replacement ● Memory Safety without Garbage Collection ● No runtime needed ● Rich Typesystem ● Strong Functional Programming influence ● Improving your toolkit

Slide 36

Slide 36 text

Thanks! @dvigneshwer [email protected] https://tinyurl.com/FOSSASIA18