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



##########
File path: python/tvm/micro/interface_api.py
##########
@@ -0,0 +1,81 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Defines functions for generating a C interface header"""
+
+import os
+
+from tvm.relay.backend.utils import mangle_module_name
+
+
+def _emit_brief(header_file, model_name, description):
+    header_file.write("/*!\n")
+    header_file.write(f" * \\brief TVM {model_name} model {description} \n")
+    header_file.write(" */\n")
+
+
+def generate_c_interface_header(model_name, inputs, outputs, output_path):
+    """Generates a C interface header for a given models inputs and outputs
+
+    Parameters
+    ----------
+    model_name : str
+        Name of the model to be used in defining structs and naming the header
+    inputs : list[str]
+        List of model input names to be placed in generated structs
+    outputs : list[str]
+        List of model output names to be placed in generated structs
+    output_path : str
+        Path to the output folder to generate the header into
+    """
+
+    mangled_name = mangle_module_name(model_name)
+    metadata_header = os.path.join(output_path, f"{mangled_name}.h")
+    with open(metadata_header, "w") as header_file:
+        _emit_brief(header_file, model_name, "input tensors")
+        header_file.write(f"struct {mangled_name}_inputs {{\n")

Review comment:
       since memory and devices was removed, i think what you have is fine now. 
it's pretty hard to confuse "inputs" and "outputs," since they are core 
concepts of the model (perhaps parameters may be confusing--are they inputs?). 
when we add "memory" and "devices," i'd like us to be explicit about which 
memory is intended to be there, where the user might expect to configure this 
in TVM, and which memory is not going to be there. likewise with devices--what 
should be expected, where should it get configured, and what should a user fill 
in here? but ok to merge now.




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