junrushao opened a new pull request, #15179:
URL: https://github.com/apache/tvm/pull/15179
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.testing 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)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]