Currently I'm about to merge a PR 
https://github.com/apache/incubator-tvm/pull/5310 which adds memoization logic 
for `ExprFunctor` in two different derived classes. 

I've also noticed that there are many places in the code base that have the 
same duplicated memoization logic for `ExprFunctor`, e.g
https://github.com/apache/incubator-tvm/blob/00014e20c3cc077727d467a67d3498260627e4e0/src/relay/backend/compile_engine.cc#L182-L191
https://github.com/apache/incubator-tvm/blob/00014e20c3cc077727d467a67d3498260627e4e0/src/relay/backend/graph_runtime_codegen.cc#L320

Since `ExprMutator` does have a memo built in, I wonder why `ExprFunctor` 
doesn't have it as well? I think we can clean up existing derived classes a 
lot. Is there a deep reason `ExprFunctor` cannot have a built in memoization?

Since `ExprFunctor` doesn't have memo, derived classes need to override 
`VisitExpr(const Expr& expr)` method and implement dispatching logic as well, 
in addition to memo logic.  

I think it is a good item to add to our refactoring effort. cc @tqchen @zhiics





---
[Visit 
Topic](https://discuss.tvm.ai/t/missing-memoization-in-exprfunctor/6334/1) to 
respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.ai/email/unsubscribe/e2fa975829637e4beff312a9d78930585064fe2950ed3a514467eacf3aa9f023).

Reply via email to