You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/06/18 21:08:16 UTC

[GitHub] [tvm] areusch commented on a change in pull request #8280: Introduce --interface-api={c,packed} parameter

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



##########
File path: src/target/source/source_module.cc
##########
@@ -193,24 +193,24 @@ class CSourceCrtMetadataModuleNode : public runtime::ModuleNode {
   }
 
   void GenerateEntrypointForUnpackedAPI() {
-    code_ << "TVM_DLL int32_t " << ::tvm::runtime::symbol::tvm_run_func_prefix << "(";
-    int total_args = (metadata_->num_inputs + metadata_->num_outputs);
-    for (int i = 0; i < total_args; ++i) {
-      code_ << "arg" << i;
+    code_ << "TVM_DLL int " << ::tvm::runtime::symbol::tvm_run_func_prefix << "(";

Review comment:
       since `TVMBackendPackedCFunc` use `int32_t`, i'd suggest we keep it here as well

##########
File path: python/tvm/micro/interface_api.py
##########
@@ -0,0 +1,62 @@
+# 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.
+
+import os
+
+
+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):
+    metadata_header = os.path.join(output_path, f"tvm_{model_name}.h")
+    with open(metadata_header, "w") as header_file:
+        _emit_brief(header_file, model_name, "input tensors")
+        header_file.write(f"struct tvm_{model_name}_inputs {{\n")
+        for input_name in inputs:
+            header_file.write(f"\tvoid* {input_name};\n")

Review comment:
       i know this is a holy war but i'd prefer to use spaces when generating code. in this case, i think the argument of "it always renders identically on every machine" is particularly relevant, since it's generated code




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org