tqchen opened a new pull request #5314: [IR] Allow non-nullable ObjectRef, 
introduce Optional<T>.
URL: https://github.com/apache/incubator-tvm/pull/5314
 
 
   We use ObjectRef and their sub-classes extensively throughout our codebase.
   Each of ObjectRef's sub-classes are nullable, which means they can hold 
nullptr
   as their values.
   
   While in some places we need nullptr as an alternative value. The implicit 
support
   for nullptr in all ObjectRef creates additional burdens for the developer
   to explicitly check defined in many places of the codebase.
   
   Moreover, it is unclear from the API's intentional point of view whether
   we want a nullable object or not-null version(many cases we want the later).
   
   Borrowing existing wisdoms from languages like Rust. We propose to
   introduce non-nullable ObjectRef, and Optional<T> container that
   represents a nullable variant.
   
   To keep backward compatiblity, we will start by allowing most ObjectRef to 
be nullable.
   However, we should start to use Optional<T> as the type in places where
   we know nullable is a requirement. Gradually, we will move most of the 
ObjectRef
   to be non-nullable and use Optional<T> in the nullable cases.
   
   Such explicitness in typing can help reduce the potential problems
   in our codebase overall.
   
   Changes in this PR:
   - Introduce _type_is_nullable attribute to ObjectRef
   - Introduce Optional<T>
   - Change String to be non-nullable.
   - Change the API of function->GetAttr to return Optional<T>
   
   Thanks for contributing to TVM!   Please refer to guideline 
https://tvm.apache.org/docs/contribute/ for useful information and tips. After 
the pull request is submitted, please request code reviews from 
[Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers)
 by @ them in the pull request thread.
   

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


With regards,
Apache Git Services

Reply via email to