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

[Bugfix][RPC] Allow RPCWrappedFunc to rewrite runtime::String as std::string #5796

Merged
merged 1 commit into from
Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/runtime/rpc/rpc_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ class RPCWrappedFunc : public Object {
// scan and check whether we need rewrite these arguments
// to their remote variant.
for (int i = 0; i < args.size(); ++i) {
if (args[i].IsObjectRef<String>()) {
String str = args[i];
type_codes[i] = kTVMStr;
values[i].v_str = str.c_str();
continue;
}
int tcode = type_codes[i];

switch (tcode) {
case kTVMDLTensorHandle:
case kTVMNDArrayHandle: {
Expand Down
16 changes: 16 additions & 0 deletions tests/python/unittest/test_runtime_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ def remotethrow(name):
f2 = client.get_function("rpc.test.strcat")
assert f2("abc", 11) == "abc:11"


def test_rpc_runtime_string():
if not tvm.runtime.enabled("rpc"):
return
@tvm.register_func("rpc.test.runtime_str_concat")
def strcat(x, y):
return x + y

server = rpc.Server("localhost", key="x1")
client = rpc.connect(server.host, server.port, key="x1")
func = client.get_function("rpc.test.runtime_str_concat")
x = tvm.runtime.container.String("abc")
y = tvm.runtime.container.String("def")
assert str(func(x, y)) == "abcdef"


def test_rpc_array():
if not tvm.runtime.enabled("rpc"):
return
Expand Down