syang-ng opened a new pull request #8920:
URL: https://github.com/apache/tvm/pull/8920


   Fix the bug mentioned in 
https://discuss.tvm.apache.org/t/cannot-list-attrs-of-tvm-ir-array-via-dir/10924
   
   Every time when we try to register a node, the size of `fvisit_attrs_` will 
increase, and there are no other operations to unregister these nodes, so if 
`tindex < fvisit_attrs_.size()` is true, it means that the node has been 
registered.
   
   ```c++
   template <typename T, typename TraitName>
   inline ReflectionVTable::Registry ReflectionVTable::Register() {
     uint32_t tindex = T::RuntimeTypeIndex();
     if (tindex >= fvisit_attrs_.size()) {
       fvisit_attrs_.resize(tindex + 1, nullptr);
       fcreate_.resize(tindex + 1, nullptr);
       frepr_bytes_.resize(tindex + 1, nullptr);
       fsequal_reduce_.resize(tindex + 1, nullptr);
       fshash_reduce_.resize(tindex + 1, nullptr);
     }
     // functor that implements the redirection.
     fvisit_attrs_[tindex] = ::tvm::detail::SelectVisitAttrs<T, 
TraitName>::VisitAttrs;
   
     fsequal_reduce_[tindex] = ::tvm::detail::SelectSEqualReduce<T, 
TraitName>::SEqualReduce;
   
     fshash_reduce_[tindex] = ::tvm::detail::SelectSHashReduce<T, 
TraitName>::SHashReduce;
   
     return Registry(this, tindex);
   }
   ```
   
   Therefore, I just use the `tindex >= fvisit_attrs_.size()` to determine 
whether it has been registered. And if `fvisit_attrs_[tindex] != nullptr` 
exists, I will execute `fvisit_attrs_[tindex](self, visitor);` to get its 
attribute


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to