This is an automated email from the ASF dual-hosted git repository.
yaxingcai pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git
The following commit(s) were added to refs/heads/dev by this push:
new 7163aeb [DOCS] Fix lint and improve docs (#13)
7163aeb is described below
commit 7163aeba46e572d7f979f83d47b56ecec4e49ec6
Author: Tianqi Chen <[email protected]>
AuthorDate: Sun Sep 14 18:31:31 2025 -0400
[DOCS] Fix lint and improve docs (#13)
This PR fixes previous lint error
also improves docs
---
.asf.yaml | 3 ++-
cmake/Utils/AddGoogleTest.cmake | 1 +
docs/guides/compiler_integration.md | 25 +++++++++++++------------
docs/reference/python/cpp/index.rst | 17 +++++++++++++++++
4 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/.asf.yaml b/.asf.yaml
index 4893631..b5bf070 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -29,7 +29,8 @@ github:
# in a separate branch(e.g. dev), confirm things works
# before changing it to main
dev:
- # note: do not set status check for now before we setup skip ci
+ # note: do not set status check for now
+ # committer will check ci status before merging
required_pull_request_reviews:
required_approving_review_count: 1
diff --git a/cmake/Utils/AddGoogleTest.cmake b/cmake/Utils/AddGoogleTest.cmake
index af84175..e5a7a84 100644
--- a/cmake/Utils/AddGoogleTest.cmake
+++ b/cmake/Utils/AddGoogleTest.cmake
@@ -48,6 +48,7 @@ macro(tvm_ffi_add_googletest target_name)
target_link_libraries(${target_name} PRIVATE gtest_main)
gtest_discover_tests(${target_name}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ TEST_DISCOVERY_TIMEOUT 300
DISCOVERY_MODE PRE_TEST
PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
diff --git a/docs/guides/compiler_integration.md
b/docs/guides/compiler_integration.md
index eedebff..96f5b2f 100644
--- a/docs/guides/compiler_integration.md
+++ b/docs/guides/compiler_integration.md
@@ -29,9 +29,10 @@ build code. To connect these functions to the FFI
convention, one can use the
following options:
- For compilers that generate host functions via codegen (e.g., LLVM), one can
- generate the symbol `__tvm_ffi_func_name` directly following the ABI
convention.
+ generate the symbol `__tvm_ffi_<func_name>`, where `<funcname>` is the
exported
+ function.
- For kernel generators that generate C++ host code, one can directly
- use `TVM_FFI_DLL_EXPORT_TYPED_FUNC` to expose the symbol.
+ use {c:macro}`TVM_FFI_DLL_EXPORT_TYPED_FUNC` to expose the symbol.
The following code snippet shows C code that corresponds to a
function performing `add_one` under the ABI. It is reasonably straightforward
for
@@ -77,8 +78,8 @@ int __tvm_ffi_add_one(
Some of the key takeaways include:
- Prefix the symbol with `__tvm_ffi_`
-- Call `TVMFFIEnvGetStream` to get the current environment stream
-- Use return value for error handling, set error via
`TVMFFIErrorSetRaisedFromCStr`.
+- Call {cpp:func}`TVMFFIEnvGetStream` to get the current environment stream
+- Use return value for error handling, set error via
{cpp:func}`TVMFFIErrorSetRaisedFromCStr`.
You can also check out the [ABI overview](../concepts/abi_overview.md) for a
more complete guide.
@@ -95,7 +96,7 @@ Op.call_tvm_ffi("my_func", *args)
global functions that are registered and invoke them.
- For ahead-of-time compilation (AOT) with minimum runtime, the AOT compiler
can generate
direct calls into FFI functions:
- - Use the TVMFFIFunctionCall API to call into custom `ffi::Function`s
+ - Use the TVMFFIFunctionCall API to call into custom
{cpp:class}`tvm::ffi::Function`s
- If the function exposes a C symbol following the FFI ABI, call it directly.
This approach provides a unified mechanism to call into any libraries and
other DSLs
@@ -106,16 +107,16 @@ with various kernel DSLs and libraries.
While the standard dynamic library module is sufficient for many use cases,
sometimes it may be helpful to package a custom runtime module that wraps over
a driver API.
-For example, using `cuModuleLoad` explicitly to load generated PTX code and
expose it as an `ffi::Function`.
+For example, using `cuModuleLoad` explicitly to load generated PTX code and
expose it as an {cpp:class}`tvm::ffi::Function`.
The {cpp:class}`tvm::ffi::ModuleObj` interface provides a way to support this
need.
-Generally, the steps include subclassing the `tvm::ffi::ModuleObj`:
+Generally, the steps include subclassing the {cpp:class}`tvm::ffi::ModuleObj`:
-- Provide a specific `kind` string to identify the module type
-- Override `GetPropertyMask` to indicate:
+- Provide a specific {cpp:func}`tvm::ffi::ModuleObj::kind` string to identify
the module type
+- Override {cpp:func}`tvm::ffi::ModuleObj::GetPropertyMask` to indicate:
- The module is `ffi::Module::kRunnable` (executable)
- If binary serialization is supported, also add
`ffi::Module::kBinarySerializable`
-- Override `GetFunction` to specify how functions can be loaded from custom
data
-- Register binary serialization/deserialization `SaveToBytes` and register a
global
+- Override {cpp:func}`tvm::ffi::ModuleObj::GetFunction` to specify how
functions loaded
+- Register binary serialization/deserialization
{cpp:func}`tvm::ffi::ModuleObj::SaveToBytes` and register a global
function `ffi.Module.load_from_bytes.<kind>`
### Enable Export and Loading
@@ -128,7 +129,7 @@ We allow libraries to embed a binary symbol
`__tvm_ffi__library_bin` in the foll
- `<import_tree>` uses CSR sparse array format: `<indptr: vec<u64>>
<child_indices: vec<u64>>`
to store child indices of each node (each node is a Module instance)
- `<key>` stores the module kind, or can be `_lib`:
- - `_lib` indicates the module corresponds to the dynamic library itself with
functions in shared library symbols
+ - `_lib` indicates the module corresponds to the dynamic library itself
- For other cases, `val: bytes` contains the serialized bytes from the
custom module
- Both `bytes` and `str` are serialized as `<size: u64> <content>`
diff --git a/docs/reference/python/cpp/index.rst
b/docs/reference/python/cpp/index.rst
index 8737633..c104335 100644
--- a/docs/reference/python/cpp/index.rst
+++ b/docs/reference/python/cpp/index.rst
@@ -1,3 +1,20 @@
+.. 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.
+
tvm_ffi.cpp
-----------