gemini-code-assist[bot] commented on code in PR #331:
URL: https://github.com/apache/tvm-ffi/pull/331#discussion_r2609507650
##########
python/tvm_ffi/module.py:
##########
@@ -374,6 +374,77 @@ def write_to_file(self, file_name: str, fmt: str = "") ->
None:
"""
_ffi_api.ModuleWriteToFile(self, file_name, fmt)
+ def save_to_bytes(self) -> bytes:
+ """Serialize the current module to bytes.
+
+ Returns
+ -------
+ The serialized module in bytes.
+
+ See Also
+ --------
+ :py:meth:`load_from_bytes`: load module from bytes.
+
+ """
+ return _ffi_api.ModuleSaveToBytes(self)
+
+ @staticmethod
+ def load_from_bytes(kind: str, byte_array: bytes) -> Module:
+ """Load module from bytes.
+
+ Parameters
+ ----------
+ kind
+ The kind of the module.
+ byte_array
+ The byte array.
+
+ Returns
+ -------
+ The loaded module.
+
+ See Also
+ --------
+ :py:meth:`save_to_bytes`: serialize module to bytes.
+
+ """
+ return _ffi_api.ModuleLoadFromBytes(kind, byte_array)
+
+ def close(self) -> None:
+ """Explicitly close the module if applicable, i.e., unload the dynamic
library.
+
+ Notes
+ -----
+ This function is a no-op for modules that do not support unloading.
+ The destructor of modules will also call close() as long as the module
is not
+ being kept alive via `set_keep_alive(True)`.
+
+ See Also
+ --------
+ :py:meth:`set_keep_alive`: Set whether to keep the module alive.
+
+ """
+ _ffi_api.ModuleClose(self)
+
+ def set_keep_alive(self, keep_alive: bool) -> None:
+ """For unloadable modules, if `keep_alive` is set to true, the module
will not be unloaded in its destructor; otherwise, it will be unloaded when the
module is destructed.
Review Comment:

The docstring summary line is very long. According to Python's PEP 257
docstring conventions, it's better to have a short, single-line summary,
followed by a blank line, and then a more detailed description. This improves
readability.
```suggestion
"""Set whether to keep the module alive after destruction.\n\n
For unloadable modules, if `keep_alive` is set to true, the module will not
be\n unloaded in its destructor; otherwise, it will be unloaded when the
module is\n destructed.
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]