MCPcopy Create free account
hub / github.com/apache/tvm / Tracker

Class Tracker

python/tvm/rpc/tracker.py:457–523  ·  view source on GitHub ↗

Start RPC tracker on a separate process. Python implementation based on PopenWorker. Parameters ---------- host : str The host url of the server. port : int The TCP port to be bind to port_end : int, optional The end TCP port to search silent:

Source from the content-addressed store, hash-verified

455
456
457class Tracker:
458 """Start RPC tracker on a separate process.
459
460 Python implementation based on PopenWorker.
461
462 Parameters
463 ----------
464 host : str
465 The host url of the server.
466
467 port : int
468 The TCP port to be bind to
469
470 port_end : int, optional
471 The end TCP port to search
472
473 silent: bool, optional
474 Whether run in silent mode
475
476 reuse_addr: bool, optional
477 Allows the kernel to reuse a local socket in TIME_WAIT state.
478
479 timeout: float, optional
480 set a timeout for all operations on the socket
481
482 """
483
484 def __init__(
485 self, host="0.0.0.0", port=9190, port_end=9199, silent=False, reuse_addr=True, timeout=None
486 ):
487 if silent:
488 logger.setLevel(logging.WARN)
489 self.proc = PopenWorker()
490 # send the function
491 self.proc.send(
492 _popen_start_tracker_server, [host, port, port_end, silent, reuse_addr, timeout]
493 )
494 # receive the port
495 self.port, self.stop_key = self.proc.recv()
496 self.host = host
497
498 def _stop_tracker(self):
499 sock = socket.socket(base.get_addr_family((self.host, self.port)), socket.SOCK_STREAM)
500 sock.connect(("127.0.0.1", self.port))
501 sock.sendall(struct.pack("<i", base.RPC_TRACKER_MAGIC))
502 magic = struct.unpack("<i", base.recvall(sock, 4))[0]
503 assert magic == base.RPC_TRACKER_MAGIC
504 base.sendjson(sock, [TrackerCode.STOP, self.stop_key])
505 assert base.recvjson(sock) == TrackerCode.SUCCESS
506 sock.close()
507
508 def terminate(self):
509 """Terminate the server process"""
510 if self.proc:
511 if self.proc.is_alive():
512 self._stop_tracker()
513 self.proc.join(0.1)
514 if self.proc.is_alive():

Callers 6

__init__Method · 0.90
test_rpc_tracker_requestFunction · 0.90
mainFunction · 0.85

Calls

no outgoing calls

Tested by 4

test_rpc_tracker_requestFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…