-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RELAY][TypeSystem] Add support for populating type args #1962
Conversation
include/tvm/relay/expr.h
Outdated
@@ -267,7 +267,7 @@ class CallNode : public ExprNode { | |||
* | |||
* \endcode | |||
*/ | |||
tvm::Array<Type> type_args; | |||
mutable tvm::Array<Type> type_args; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
include/tvm/relay/expr.h
Outdated
@@ -267,7 +267,7 @@ class CallNode : public ExprNode { | |||
* | |||
* \endcode | |||
*/ | |||
tvm::Array<Type> type_args; | |||
mutable tvm::Array<Type> type_args; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree using const cast selectively is a better approach
src/relay/pass/type_infer.cc
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can change AttachCheckedType -> AttachTypeInfo, and directly attach type_args when it is defined
src/relay/pass/type_infer.cc
Outdated
|
||
Type checked_type; | ||
// Only allocated when the expression is a call. | ||
Array<Type> type_args; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
src/relay/ir/text_printer.cc
Outdated
@@ -277,16 +277,30 @@ class TextPrinter : | |||
TextValue VisitExpr_(const CallNode* op) final { | |||
// TODO(tqchen, M.K.): support generic call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the todo
src/relay/pass/type_infer.cc
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove extra space?
@tqchen Should be good to go modulo CI. |
src/relay/pass/type_infer.cc
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likely you don't need this, as long as there are default constructor with no argument
src/relay/pass/type_infer.cc
Outdated
: 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to initalized checked_type, it will pick the default constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.