[Testing] Utility method to run TVM on remote device#15179
Merged
MasterJH5574 merged 1 commit intoapache:mainfrom Jun 29, 2023
Merged
[Testing] Utility method to run TVM on remote device#15179MasterJH5574 merged 1 commit intoapache:mainfrom
MasterJH5574 merged 1 commit intoapache:mainfrom
Conversation
Collaborator
|
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
eb79389 to
be0d401
Compare
be0d401 to
a1395ca
Compare
This PR introduces `tvm.testing.rpc_run`, a utility method that allows a
`runtime.Module` to run on a remote device via TVM RPC.
Example:
```python
import numpy as np
import tvm
from tvm.script import tir as T
from tvm.testnig import rpc_run
@T.prim_func
def cuda_kernel(
A: T.Buffer((128,), "float32"),
B: T.Buffer((128,), "float32"),
):
for bx in T.thread_binding(4, thread="blockIdx.x"):
for tx in T.thread_binding(32, thread="threadIdx.x"):
x = bx * 32 + tx
B[x] = A[x] + 1.0
def main():
np_a = np.random.randn(128).astype("float32")
np_b = np_a + 1.0
rt_mod = tvm.build(cuda_kernel, target="nvidia/geforce-rtx-3090-ti")
tvm_a, tvm_b = rpc_run(
rt_mod,
"cuda",
[np_a, np_b],
)
assert np.allclose(tvm_b, np_b)
```
Result:
```
Execution time summary:
mean (ms) median (ms) max (ms) min (ms) std (ms)
0.0023 0.0023 0.0023 0.0023 0.0000
```
a1395ca to
761b4e7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces
tvm.testing.rpc_run, a utility method that allows aruntime.Moduleto run on a remote device via TVM RPC.Example:
Result: