hanzz2007 opened a new issue #6093:
URL: https://github.com/apache/incubator-tvm/issues/6093


   ```C++ 
   template <typename FFind>
   class AttrInitVisitor {
    public:
     // Counter of number of matched attributes during visit.
     // This is used to decide if there is additional unmatched attributes.
     size_t hit_count_{0};
     // constructor
     AttrInitVisitor(const char* type_key, FFind ffind) : type_key_(type_key), 
ffind_(ffind) {}
   
     template <typename T>
     AttrInitEntry<T> operator()(const char* key, T* value) {  
       TVMArgValue val;
       AttrInitEntry<T> opt;
       opt.type_key_ = type_key_;
       opt.key_ = key;
       opt.value_ = value;
       if (ffind_(key, &val)) {
         SetValue(value, val);
         opt.value_missing_ = false;
         ++hit_count_;
       } else {
         opt.value_missing_ = true;
       }
   
       return opt;
      // for compilers without RVO optimization, the opt.~AttrInitEntry<T>() 
will be called when function exit 
      // An exception will be throwed if opt.value_missing_ is ture in 
destructor
     }
   ```
   When the AttrsNode is first constructed
   ```C++
   template <typename TAttrs>
   inline TAttrs AttrsWithDefaultValues() {
     static_assert(std::is_base_of<Attrs, TAttrs>::value, "Can only take attr 
nodes");
     auto n = make_object<typename TAttrs::ContainerType>();
     // Note here, will cause a problem
     n->InitByPackedArgs(runtime::TVMArgs(nullptr, nullptr, 0), false);
     return TAttrs(n);
   }
   ```
   
   Maybe we could fix it via the following codes
   
   https://gist.github.com/hanzz2007/803b28a7915c31686cffce0ac6450b73
   https://gist.github.com/hanzz2007/e42b14b51c8c9c765cca107867e64d49
   
   
   


----------------------------------------------------------------
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.

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


Reply via email to