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

@hypercubestarthypercubestart 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

@yzhliuyzhliu 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
ContributorAuthor

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

Comment threadsrc/relay/transforms/defunctionalization.cc Outdated
Comment threadsrc/relay/transforms/defunctionalization.cc Outdated
Comment threadsrc/relay/transforms/defunctionalization.cc Outdated
Comment threadsrc/relay/transforms/defunctionalization.cc Outdated
Comment threadtests/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 threadsrc/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 threadsrc/relay/transforms/defunctionalization.cc Outdated
Comment threadsrc/relay/transforms/defunctionalization.cc Outdated

@MarisaKirisameMarisaKirisame 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
ContributorAuthor

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:masterSep 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 freeto 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

@hypercubestart@MarisaKirisame@yzhliu@ZihengJiang