areusch commented on a change in pull request #8380:
URL: https://github.com/apache/tvm/pull/8380#discussion_r673519098



##########
File path: python/tvm/micro/project.py
##########
@@ -0,0 +1,97 @@
+"""Defines glue wrappers around the Project API which mate to TVM 
interfaces."""
+
+from ..contrib import utils
+from .build import get_standalone_crt_dir
+from .model_library_format import export_model_library_format
+from .project_api import client
+from .transport import Transport, TransportTimeouts
+
+
+class ProjectTransport(Transport):
+
+    def __init__(self, client, options):
+        self._client = client
+        self._options = options
+        self._timeouts = None
+
+    def timeouts(self):
+        assert self._timeouts is not None, "Transport not yet opened"
+        return self._timeouts
+
+    def open(self):
+        reply = self._client.connect_transport(self._options)
+        self._timeouts = TransportTimeouts(**reply["timeouts"])
+
+    def close(self):
+        self._client.disconnect_transport()
+
+    def write(self, data, timeout_sec):
+        return self._client.write_transport(data, timeout_sec)["bytes_written"]
+
+    def read(self, n, timeout_sec):
+        return self._client.read_transport(n, timeout_sec)["data"]
+
+
+class TemplateProjectError(Exception):
+    """Raised when the Project API server given to GeneratedProject reports 
is_template=True."""
+
+
+class GeneratedProject:
+    """Defines a glue interface to interact with a generated project through 
the API server."""
+
+    @classmethod
+    def from_directory(cls, project_dir, options):
+        return cls(client.instantiate_from_dir(project_dir), options)
+
+    def __init__(self, client, options):
+        self._client = client
+        self._options = options
+        self._info = self._client.server_info_query()
+        if self._info['is_template']:
+            raise TemplateProjectError()
+

Review comment:
       could you say why? right now this code is just attempting to document 
the uses of project_api. i think we don't need to expose that here if it's not 
called. wdyt?




-- 
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]


Reply via email to