Skip to content

[Relay] Add Defunctionalization Pass - #6400

Merged
MarisaKirisame merged 17 commits into
apache:masterfrom
hypercubestart:defunc
Sep 10, 2020
Merged

[Relay] Add Defunctionalization Pass #6400
MarisaKirisame merged 17 commits into
apache:masterfrom
hypercubestart:defunc

Conversation

@hypercubestart

@hypercubestart hypercubestart commented Sep 4, 2020

Copy link
Copy Markdown
Contributor

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

@yzhliu yzhliu left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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

hypercubestart commented Sep 4, 2020

Copy link
Copy Markdown
Contributor Author

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

Comment thread src/relay/transforms/defunctionalization.cc Outdated
Comment thread src/relay/transforms/defunctionalization.cc Outdated
Comment thread src/relay/transforms/defunctionalization.cc Outdated
Comment thread src/relay/transforms/defunctionalization.cc Outdated
Comment thread tests/python/relay/test_pass_defunctionalization.py Outdated
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

check eq size

Comment thread src/relay/transforms/defunctionalization.cc Outdated
continue;
}

// we assume arg is either an identifier (var or globalvar) or a function

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

Comment thread src/relay/transforms/defunctionalization.cc Outdated
Comment thread src/relay/transforms/defunctionalization.cc Outdated

@MarisaKirisame MarisaKirisame left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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