-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Relay] Add Defunctionalization Pass #6400
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
Conversation
yzhliu
left a comment
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.
Please also tag ppl for review.
| raise Exception('unknown mode') | ||
|
|
||
| def Defunctionalization(expr, mod): | ||
| """ |
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.
Please add some description.
|
cc: @wweic @MarisaKirisame @zhiics @icemelon9 @ZihengJiang @jroesch @tqchen |
| Function Specialize(const Function& f, const Array<Type> type_args) { | ||
| auto map = tvm::Map<TypeVar, Type>(); | ||
| for (size_t i = 0; i < type_args.size(); i++) { | ||
| map.Set(f->type_params[i], type_args[i]); |
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.
check eq size
| continue; | ||
| } | ||
|
|
||
| // we assume arg is either an identifier (var or globalvar) or a function |
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.
refactor the stuff after continue into a function
4e26a9d to
d2d2f35
Compare
MarisaKirisame
left a comment
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.
pretty good. one more small nit, and please fix the CI.
| continue; | ||
| } | ||
|
|
||
| args.push_back(EncodeArg(arg, 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.
if else is a better style then continue.
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.
yep, looks like CI issue was caused by this: #6434
d2d2f35 to
a573c17
Compare
|
Thx @hypercubestart @yzhliu . |
* type args not automatically inferred... * working on type arg infer * fix type arg infer * WIP * wip * wip * revert type_infer * working * fix up test * fix * remove DeGlobal * lint * fix std move * comments * fix comments * review * style
* type args not automatically inferred... * working on type arg infer * fix type arg infer * WIP * wip * wip * revert type_infer * working * fix up test * fix * remove DeGlobal * lint * fix std move * comments * fix comments * review * style
* type args not automatically inferred... * working on type arg infer * fix type arg infer * WIP * wip * wip * revert type_infer * working * fix up test * fix * remove DeGlobal * lint * fix std move * comments * fix comments * review * style
introduces a defunctionalization pass based upon Type-Driven Defunctionalization, transforming a higher-order functional program into a first-order program.
currently it assumes a number of characteristics about the program, and will be extended upon in future work