MCPcopy Index your code
hub / github.com/apache/tvm / RPCTest

Class RPCTest

jvm/core/src/test/java/org/apache/tvm/rpc/RPCTest.java:31–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29import org.slf4j.LoggerFactory;
30
31public class RPCTest {
32 private final Logger logger = LoggerFactory.getLogger(RPCTest.class);
33
34 @Ignore("RPC test is not enabled")
35 @Test
36 public void test_addone() {
37 if (!Module.enabled("rpc")) {
38 logger.warn("RPC is not enabled. Skip.");
39 return;
40 }
41 Function.register("test.rpc.addone", new Function.Callback() {
42 @Override
43 public Object invoke(TVMValue... args) {
44 return args[0].asLong() + 1L;
45 }
46 });
47
48 TestUtils.RefInt port = new TestUtils.RefInt();
49 Server server = null;
50 try {
51 server = TestUtils.startServer(port);
52 RPCSession client = Client.connect("127.0.0.1", port.value);
53 Function func = client.getFunction("test.rpc.addone");
54 assertEquals(11L, func.call(10).asLong());
55 } finally {
56 if (server != null) {
57 server.terminate();
58 }
59 }
60 }
61
62 @Ignore("RPC test is not enabled")
63 @Test
64 public void test_strcat() {
65 if (!Module.enabled("rpc")) {
66 logger.warn("RPC is not enabled. Skip.");
67 return;
68 }
69 Function.register("test.rpc.strcat", new Function.Callback() {
70 @Override
71 public Object invoke(TVMValue... args) {
72 return args[0].asString() + ":" + args[1].asLong();
73 }
74 });
75
76 TestUtils.RefInt port = new TestUtils.RefInt();
77 Server server = null;
78 try {
79 server = TestUtils.startServer(port);
80 RPCSession client = Client.connect("127.0.0.1", port.value);
81 Function func = client.getFunction("test.rpc.strcat");
82 assertEquals("abc:11", func.call("abc", 11L).asString());
83 } finally {
84 if (server != null) {
85 server.terminate();
86 }
87 }
88 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…