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] Add shape_of instruction #5855

Merged
merged 7 commits into from
Jun 28, 2020
Merged

Conversation

zhiics
Copy link
Member

@zhiics zhiics commented Jun 19, 2020

This PR adds a VM instruction ShapeOf to get the shape of a tensor at runtime. This instruction is always executed on CPU as there is no computation required.

cc @icemelon9 @jroesch @wweic

@zhiics zhiics force-pushed the memory_shape_of branch from 0e3c9ae to 9b32292 Compare June 19, 2020 17:56
@jroesch
Copy link
Member

jroesch commented Jun 23, 2020

cc @mbrookhart

Copy link
Contributor

@mbrookhart mbrookhart left a comment

Choose a reason for hiding this comment

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

I presume this is to make heterogeneous execution easier? Should we add a pass to the VM that converts regular shape_of ops to vm.shape_of ops for easier use?

tests/python/relay/test_vm_serialization.py Show resolved Hide resolved
Copy link
Contributor

@mbrookhart mbrookhart left a comment

Choose a reason for hiding this comment

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

LGTM

tests/python/relay/test_vm_serialization.py Show resolved Hide resolved
@icemelon
Copy link
Member

I feel we should treat ops like vm.shape_of as a dialect for vm. Therefore the conversion from relay ops to vm dialect ops should not be inside the manifest memory pass, but a separate pass.

@jroesch @tqchen What's your thoughts on this?

@zhiics zhiics force-pushed the memory_shape_of branch from 1c92ccd to 793be8d Compare June 23, 2020 21:33
@@ -0,0 +1,35 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
Copy link
Member

Choose a reason for hiding this comment

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

Let us simply use relay.op.vm and mark it as a dialect in the comment. Since QNN is also a dialect but does not belong to the dialect namespace

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing out. I changed it to relay.op.vm. Maybe we should have such a namespace in the long run? Likely, we can have dialect.vm, dialect.memory, dialect.qnn, etc.

python/tvm/relay/op/dialect/_make.py Outdated Show resolved Hide resolved
Copy link
Member

@icemelon icemelon left a comment

Choose a reason for hiding this comment

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

LGTM

src/relay/op/vm/vm.cc Outdated Show resolved Hide resolved
@zhiics
Copy link
Member Author

zhiics commented Jun 28, 2020

@tqchen could you please take another look?

@tqchen tqchen merged commit 7312934 into apache:master Jun 28, 2020
@zhiics zhiics deleted the memory_shape_of branch June 28, 2020 17:24
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 30, 2020
zhiics added a commit to neo-ai/tvm that referenced this pull request Jul 2, 2020
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.

5 participants