yaoyaoding commented on code in PR #213:
URL: https://github.com/apache/tvm-ffi/pull/213#discussion_r2482388883
##########
python/tvm_ffi/cpp/load_inline.py:
##########
@@ -360,7 +417,16 @@ def _decorate_with_tvm_ffi(source: str, functions:
Mapping[str, str]) -> str:
return "\n".join(sources)
-def build_inline( # noqa: PLR0915, PLR0912
+def _str_seq2list(seq: Sequence[str] | str | None) -> list[str]:
+ if seq is None:
+ return []
+ elif isinstance(seq, str):
+ return [seq]
+ else:
+ return list(seq)
+
+
+def build_inline(
Review Comment:
with the new `build` function, this function can be refactored to
1. decorate the sources given functions to export
2. write the sources to build directory
3. use `build` function to build the shard library
##########
python/tvm_ffi/cpp/load_inline.py:
##########
@@ -702,3 +760,94 @@ def load_inline(
build_directory=build_directory,
)
)
+
+
+def build(
+ name: str,
+ *,
+ cpp_files: Sequence[str] | str | None = None,
+ cuda_files: Sequence[str] | str | None = None,
+ extra_cflags: Sequence[str] | None = None,
+ extra_cuda_cflags: Sequence[str] | None = None,
+ extra_ldflags: Sequence[str] | None = None,
+ extra_include_paths: Sequence[str] | None = None,
+ build_directory: str | None = None,
+) -> str:
+ """Compile and build a C++/CUDA module from source files."""
Review Comment:
Add more detailed documentation for this function, and `build_and_load`
function.
Then add these two new functions to
https://github.com/apache/tvm-ffi/blob/main/docs/reference/python/index.rst?plain=1#L105-L114
section.
It's also good to rename the section from "inline loading" to something like
"cpp extension" or "cpp utility".
--
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]