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 2022/11/22 09:24:00 UTC

[GitHub] [tvm] fPecc commented on a diff in pull request #12789: Added macro generation in MLF export

fPecc commented on code in PR #12789:
URL: https://github.com/apache/tvm/pull/12789#discussion_r1029073124


##########
python/tvm/micro/model_library_format.py:
##########
@@ -277,6 +294,37 @@ def _create_empty_entry(target_device_type):
             main_func_metadata.io_sizes[target]
         )
 
+        # Now, we also add the information about the size of each input and output of the main
+        # function (in bytes)
+        input_dict = {}
+        for input_param in main_func_metadata.relay_primfuncs[target].params:
+            if hasattr(input_param, "checked_type"):
+                input_dict[input_param.name_hint] = int(
+                    _shape_to_size(input_param.checked_type.shape, input_param.checked_type.dtype)
+                )
+            else:
+                # TODO: maybe fill checked_type here?
+                input_dict[input_param.name_hint] = 0
+        target_main_entries[int(target.kind.device_type)]["inputs"] = input_dict
+
+        output_dict = {}
+        # For output, we dont have the name of the output, so we enumerate them
+        if isinstance(main_func_metadata.relay_primfuncs[target].ret_type, tvm.ir.type.TupleType):
+            for i, output_type in enumerate(
+                main_func_metadata.relay_primfuncs[target].ret_type.fields
+            ):
+                if hasattr(output_type, "shape"):
+                    output_dict[i] = int(_shape_to_size(output_type.shape, output_type.dtype))
+                else:
+                    output_dict[i] = 0
+        else:
+            output_type = main_func_metadata.relay_primfuncs[target].ret_type
+            if hasattr(output_type, "shape"):
+                output_dict[0] = int(_shape_to_size(output_type.shape, output_type.dtype))
+            else:
+                output_dict[0] = 0

Review Comment:
   Applied the proposed change



-- 
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: commits-unsubscribe@tvm.apache.org

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