Commit fbb74892 by Logan Weber Committed by Jared Roesch

[Relay] Add compiler pass tutorial docs (#2746)

* Add Relay compiler pass tutorial docs

* Add Python API hook wrapping step

* Incorporate feedback

* More doc iteration

* Mooooore iteration

* Rewrite `runtime.md` in rst
parent 5293c6bf
...@@ -31,4 +31,5 @@ In this part of documentation, we share the rationale for the specific choices m ...@@ -31,4 +31,5 @@ In this part of documentation, we share the rationale for the specific choices m
hybrid_script hybrid_script
relay_intro relay_intro
relay_add_op relay_add_op
relay_add_pass
codebase_walkthrough codebase_walkthrough
...@@ -35,8 +35,11 @@ using FInterpreter = runtime::TypedPackedFunc<Value(Expr)>; ...@@ -35,8 +35,11 @@ using FInterpreter = runtime::TypedPackedFunc<Value(Expr)>;
class ConstantChecker : private ExprVisitor { class ConstantChecker : private ExprVisitor {
public: public:
// Check whether an expression is constant. The results are memorized. // Check whether an expression is constant. The results are memoized.
bool Check(const Expr& expr) { bool Check(const Expr& expr) {
// The `ConstantNode` case is common enough that we check directly for the
// case here, to avoid the time overhead of dispatching through the vtable
// and the space overhead of memoizing always-true results.
if (expr.as<ConstantNode>()) { if (expr.as<ConstantNode>()) {
return true; return true;
} }
...@@ -44,7 +47,7 @@ class ConstantChecker : private ExprVisitor { ...@@ -44,7 +47,7 @@ class ConstantChecker : private ExprVisitor {
if (it != memo_.end()) if (it != memo_.end())
return it->second; return it->second;
VisitExpr(expr); VisitExpr(expr);
return memo_[expr]; // return memorized result or the default value false return memo_[expr]; // return memoized result or the default value false
} }
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment