right now relay aot/interpreter/vm all use reference counting to collect memory. However, it is possible to create cyclic data structure in relay, as demonstrated below:
data Loop = Ref (Optional Loop) x : Loop = Ref None match x with | r -> r := x end in short, we can has a data type holding a mutable (nullable) reference, initialize it to null, then point it to itself. This example is purely contrived, but it is completely possible in real, meaningful relay code: imagine a doubly linked list, or two closure referencing each other. They all form cyclic link data which will never be collected by reference counting. there are three problem we should discuss: 0: what algorithm should we use? mark and sweep/generational, etc? 1: should we still use reference counting? 2: how can we implement the runtime only once, for aot/interpreter/vm, instead of each of them having to implement the runtime itself? maybe we can look at https://github.com/hsutter/gcpp? @jroesch @tqchen @icemelon9 @wweic @junrushao1994 @nhynes any suggestion? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/dmlc/tvm/issues/3423