Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private...

29
Program Analysis in Relay Gus Smith December 5th, 2019

Transcript of Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private...

Page 1: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Program Analysis in RelayGus Smith

December 5th, 2019

Page 2: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Page 3: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Page 4: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Page 5: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Page 6: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Page 7: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Page 8: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Page 9: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)
Page 10: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)
Page 11: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)
Page 12: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

There’s no Relay-sanctioned way to build program analyses!

Page 13: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

This leads to problems:

Page 14: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

This leads to problems:

• Duplication of effort

Page 15: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

This leads to problems:

• Duplication of effort

• High barrier to entry for new developers

Page 16: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

This leads to problems:

• Duplication of effort

• High barrier to entry for new developers

• Less readability and maintainability

Page 17: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)
Page 18: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)
Page 19: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)
Page 20: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Needs documentation!

Page 21: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Needs documentation!

Needs a standard data interchange format!

Page 22: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Needs documentation!

Needs a standard data interchange format!

…and needs to be discoverable/accessible!

Page 23: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

What do we want in an analysis framework?

Page 24: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

What do we want in an analysis framework?

• Supports many types of program analyses

Page 25: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

What do we want in an analysis framework?

• Supports many types of program analyses

• Quick to write new analyses

Page 26: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

What do we want in an analysis framework?

• Supports many types of program analyses

• Quick to write new analyses

• Promotes composing analyses together

Page 27: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

https://github.com/microsoft/Analysis-Framework-for-TVM

Page 28: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

https://github.com/gussmith23/tvm/blob/analysis-framework-demo/demo.ipynb

Page 29: Program Analysis in Relay - SAMPL: Home1 class MacCounter 2 public: MacCounter count private ExprVisitor { 19 29 static int64_t Get TotalMacNumber(const Expr& expr) { LOG (INFO)

Moving forward

https://github.com/apache/incubator-tvm/issues/4449