[quote="tqchen, post:4, topic:6334"] The addtional cost for memo is not taking a lot of locs [/quote]
Note that in addition to the memo logic itself, we can also remove `VisitExpr(const Expr& expr)` override in the derived classes (which to me seems only exist for memoization), and hence the dispatching logic like this can be also removed: https://github.com/apache/incubator-tvm/blob/00014e20c3cc077727d467a67d3498260627e4e0/src/relay/backend/graph_runtime_codegen.cc#L322-L352 I think this dispatching logic is already handled by `ExprFunctor`. So if the base class has memo logic built in, dervied classes don't need to `VisitExpr(const Expr& expr)` override at all. The PR https://github.com/apache/incubator-tvm/pull/5310/ also has this dispatch logic in `VisitExpr(const Expr& expr)` override. Moreover, without memoization in the base class, all external codegen (most of which is not public and hence we don't know how many) needs to implement memoization in the codegen backend. I actually hit "exponential blow up" error when compiling resnet with my codegen because I was missing memoization. So I think reuse opportunity of memoization in the base class is high. [quote="tqchen, post:4, topic:6334"] Given that the ExprFunctor also have additional arguments(besides the first argument), it is unclear how do we define such Memoization, unless we restrict the arguments to only contain the single one. [/quote] It seems all use of `ExprFunctor` in the code base that adds memoization on top takes a single `const Expr&` argument, so I think single argument restriction is reasonable. So given these reason I think cost-to-benefit ratio of adding `MemoziedExprFunctor` is in favor. Anyway I'll send a PR and we can decide if it is a good addition. --- [Visit Topic](https://discuss.tvm.ai/t/missing-memoization-in-exprfunctor/6334/5) 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/b19317774a274dce86a82992d7cacc10e7ea43a3c21bc9b26e308fe22543de27).