kparzysz-quic opened a new pull request #5533:
URL: https://github.com/apache/incubator-tvm/pull/5533


   The objects that the raw pointers point to can be deallocated and new 
objects can be allocated at the same address, all while these pointers are 
still in the cache. This can lead to unexpected behavior, for example to 
calculated bound conflicts with previously cached values.
   
   Internally, we have observed build failures caused by this with a message 
like
   ```
   TVMError: Check failed: (val->second->min_value == res.min_value && 
val-second->max_value == res.max_value) || (val->second->min_value == 
everything.min_value && val->second->max_value == everything.max_value): 
Detected bound for 31conflicts with memorization
   ```
   
   Caching `ObjectPtr` will prevent the objects from being deallocated while 
the cache is active.
   
   This PR has a few parts:
   1. Allowing `ObjectPtr` objects to point to `const` objects.  Since most 
object pointers are const-qualified, this will avoid casting constness away.  
The reference counter was explicitly marked as `mutable` to allow counting 
references for const objects as well.
   2. Allowing `GetObjectPtr` to automatically create `ObjectPtr` with the type 
corresponding to the input argument.  Explicit template arguments still work as 
before, but are no longer needed when the `ObjectPtr` simply wraps the argument 
type.
   3. Finally, caching `ObjectPtr<const PrimExprNode>` in the bound analyzer.


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