Skip to content

Conversation

@hypercubestart
Copy link
Contributor

@hypercubestart hypercubestart commented Sep 4, 2020

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

Copy link
Member

@yzhliu yzhliu left a 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):
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some description.

@hypercubestart
Copy link
Contributor Author

hypercubestart commented Sep 4, 2020

cc: @wweic @MarisaKirisame @zhiics @icemelon9 @ZihengJiang @jroesch @tqchen
could you guys please review?

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]);
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

@MarisaKirisame MarisaKirisame left a 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));
Copy link
Contributor

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.

Copy link
Contributor Author

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

@MarisaKirisame
Copy link
Contributor

Thx @hypercubestart @yzhliu .

@MarisaKirisame MarisaKirisame merged commit b81bdee into apache:master Sep 10, 2020
@hypercubestart hypercubestart deleted the defunc branch September 10, 2020 16:20
kevinthesun pushed a commit to kevinthesun/tvm that referenced this pull request Sep 17, 2020
* 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
kevinthesun pushed a commit to kevinthesun/tvm that referenced this pull request Sep 18, 2020
* 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
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Sep 18, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants