Skip to content
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][VM]Create closure object for GlobalVar #3411

Merged
merged 1 commit into from
Jun 22, 2019
Merged

Conversation

wweic
Copy link
Contributor

@wweic wweic commented Jun 21, 2019

For function like:

fn (%y: float32) -> float32 {
  let %x: float32 = let %x1: fn (float32) -> float32 = @lifted_name12481580008527263117
  let %add_two: fn (float32) -> float32 = @compose(%x1, %x1) /* ty=fn (float32) -> float32 */
  let %x2: float32 = %add_two(%y) /* ty=float32 */
  %x2
}

We should create a closure object for lifted_name12481580008527263117.

cc @icemelon9 @jroesch @zhiics @MarisaKirisame @slyubomirsky

@wweic wweic changed the title Create closure object for GlobalVar [Relay][VM]Create closure object for GlobalVar Jun 21, 2019
self.id = self.mod["id"]
self.compose = self.mod["compose"]
self.id = self.mod.get_global_var("id")
self.compose = self.mod.get_global_var("compose")
Copy link
Contributor

Choose a reason for hiding this comment

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

aah... why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mod["id"] returns Function. But the function name symbols need to be GlobalVar, you can check other prelude functions. Otherwise it would cause errors like https://discuss.tvm.ai/t/relay-to-a-normal-form-fails-on-a-prelude-function/3031.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see.

auto it = this->context->global_map.find(var);
CHECK(it != this->context->global_map.end());
// Allocate closure with zero free vars
Emit(Instruction::AllocClosure(it->second, 0, {}, NewRegister()));
Copy link
Member

Choose a reason for hiding this comment

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

I think we should merge for now, but eta expand these in the future then optimize/lift.

@jroesch jroesch merged commit f2406ea into apache:master Jun 22, 2019
wweic added a commit to wweic/tvm that referenced this pull request Jun 26, 2019
wweic added a commit to neo-ai/tvm that referenced this pull request Jun 27, 2019
@wweic wweic deleted the fix-gvar branch July 18, 2019 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants