[RELAY][TypeSystem] Add support for populating type args#1962
[RELAY][TypeSystem] Add support for populating type args#1962tqchen merged 7 commits intoapache:masterfrom
Conversation
| * \endcode | ||
| */ | ||
| tvm::Array<Type> type_args; | ||
| mutable tvm::Array<Type> type_args; |
There was a problem hiding this comment.
It may be better to use const cast selectively in the implementation rather then marking this field as mutable.
There was a problem hiding this comment.
I agree using const cast selectively is a better approach
Add initial version of evaluator and tests WIP Work towards simple examples in the evaluator Requires implementation of lowering ops and monomorph Evaluator now works on simple cases Restore Function case in Evaluator WIP Fix rebase issues working towards working version RTS is now working again RTS can add numbers now Fix some rebase issues Fix up tests post rebase WIP Issue type checking MLP Remove dead file Clean up evaluator Remove accidental change Reset changes from apache#1962
Add initial version of evaluator and tests WIP Work towards simple examples in the evaluator Requires implementation of lowering ops and monomorph Evaluator now works on simple cases Restore Function case in Evaluator WIP Fix rebase issues working towards working version RTS is now working again RTS can add numbers now Fix some rebase issues Fix up tests post rebase WIP Issue type checking MLP Remove dead file Clean up evaluator Remove accidental change Reset changes from apache#1962
| * \endcode | ||
| */ | ||
| tvm::Array<Type> type_args; | ||
| mutable tvm::Array<Type> type_args; |
There was a problem hiding this comment.
I agree using const cast selectively is a better approach
| auto call = GetRef<Call>(op); | ||
| auto it = tmap_.find(call); | ||
| if (it != tmap_.end()) { | ||
| Call new_op = Downcast<Call>(AttachCheckedType(op)); |
There was a problem hiding this comment.
Maybe we can change AttachCheckedType -> AttachTypeInfo, and directly attach type_args when it is defined
|
|
||
| Type checked_type; | ||
| // Only allocated when the expression is a call. | ||
| Array<Type> type_args; |
There was a problem hiding this comment.
Array type_args(NodePtr(nullptr)) // specially initialize to undefined
|
please fix the warnings here http://ci.tvm.ai:8080/blue/organizations/jenkins/tvm/detail/PR-1962/2/pipeline |
| @@ -277,16 +277,30 @@ class TextPrinter : | |||
| TextValue VisitExpr_(const CallNode* op) final { | |||
| // TODO(tqchen, M.K.): support generic call | |||
| void AddTypeArgs(const Expr& expr, Array<Type> type_args) { | ||
| auto type_info = type_map_.find(expr); | ||
| if (type_info == type_map_.end()) { | ||
| type_map_.insert({expr, ResolvedTypeInfo(type_args) }); |
There was a problem hiding this comment.
remove extra space?
|
@tqchen Should be good to go modulo CI. |
| struct ResolvedTypeInfo { | ||
| explicit ResolvedTypeInfo(Type checked_type, Array<Type> type_args) | ||
| : checked_type(checked_type), type_args(type_args) {} | ||
| ResolvedTypeInfo(const ResolvedTypeInfo& rti) |
There was a problem hiding this comment.
likely you don't need this, as long as there are default constructor with no argument
| : checked_type(checked_type), type_args(type_args) {} | ||
| ResolvedTypeInfo(const ResolvedTypeInfo& rti) | ||
| : checked_type(rti.checked_type), type_args(rti.type_args) {} | ||
| ResolvedTypeInfo() : checked_type() {} |
There was a problem hiding this comment.
no need to initalized checked_type, it will pick the default constructor
There was a problem hiding this comment.
I added these constructors due to a template instantiation error earlier.
Address feedback
524bac2 to
ba8c4cb
Compare
Add initial version of evaluator and tests WIP Work towards simple examples in the evaluator Requires implementation of lowering ops and monomorph Evaluator now works on simple cases Restore Function case in Evaluator WIP Fix rebase issues working towards working version RTS is now working again RTS can add numbers now Fix some rebase issues Fix up tests post rebase WIP Issue type checking MLP Remove dead file Clean up evaluator Remove accidental change Reset changes from apache#1962 Rename Evaluator A little clean up WIP Clean up tests WIP WIP Repair from rebase and refactor to not use MM Remove testing code which is now in apache#1969 WIP
The RTS system PR #1954 requires that we correctly populate the type arguments field. This PR adds this behavior separately and is a prerequisite for #1954.
I also added support to the text printer which was tripping an assertion otherwise.
I added one test to show this works correctly for primitive operations.