gemini-code-assist[bot] commented on code in PR #620: URL: https://github.com/apache/tvm-ffi/pull/620#discussion_r3408138243
########## AGENTS.md: ########## @@ -0,0 +1,182 @@ +<!--- 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. --> + +# AGENTS.md — Apache TVM FFI + +## What is this project? + +TVM FFI is an open ABI and FFI (Foreign Function Interface) for machine learning +systems. It provides a stable C ABI, C++17 API, Python bindings (via Cython), +and Rust bindings. The core abstractions are type-erased values (`Any`/`AnyView`), +reference-counted objects (`Object`/`ObjectRef`), and packed functions (`Function`). + +## Repository layout + +```text +include/tvm/ffi/ C++ public headers (core API) +src/ffi/ C++ implementation +python/tvm_ffi/ Python package (Cython bindings in cython/) +rust/ Rust crate workspace (tvm-ffi, tvm-ffi-sys, tvm-ffi-macros) +tests/cpp/ GoogleTest C++ tests +tests/python/ pytest Python tests +tests/lint/ Lint scripts (ASF header, file type, version check) +docs/ Sphinx documentation (RST + Markdown) +examples/ Runnable examples +cmake/Utils/ CMake utility modules +3rdparty/ Vendored deps (dlpack, libbacktrace) +addons/ Optional addons (torch_c_dlpack_ext) +``` + +## Building + +All Python commands use `uv`. The default virtualenv is `.venv` in the repo root. + +### Python editable install (primary workflow) + +```bash +uv pip install --force-reinstall --verbose -e . +``` + +C++/Cython changes always require re-running this command. Pure Python changes +are reflected immediately. + +### Update Python stubs + +After building (or after C++/Cython reflection changes), regenerate inline type stubs: + +```bash +uv run tvm-ffi-stubgen python +``` + +This updates inline stub blocks (between `tvm-ffi-stubgen(begin)` / `tvm-ffi-stubgen(end)` +markers) inside `.py` files with type annotations derived from the C++ reflection +registry (field types, method signatures, global function schemas). + +### C++-only build + +```bash +cmake . -B build_cpp -DCMAKE_BUILD_TYPE=RelWithDebInfo +cmake --build build_cpp --parallel --config RelWithDebInfo --target tvm_ffi_shared +``` + +### Prerequisites + +- Python 3.9+, C++17 compiler, CMake 3.18+, Ninja +- Submodules: `git submodule update --init --recursive` + +## Testing + +### C++ tests + +```bash +cmake . -B build_test -DTVM_FFI_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug +cmake --build build_test --clean-first --config Debug --target tvm_ffi_tests +ctest -V -C Debug --test-dir build_test --output-on-failure +``` + +### Python tests + +```bash +uv pip install --force-reinstall --verbose --group test -e . +uv run pytest -vvs tests/python +``` + +### Rust tests + +```bash +cd rust && cargo test # requires Python package installed first +``` + +## Linting + +### Pre-commit (primary lint workflow) + +```bash +pre-commit run --all-files # all hooks +pre-commit run <hook-id> --all-files # single hook (e.g. ruff-check, clang-format) +``` + +Key linters: `ruff` (Python), `clang-format` (C++, Google style, 100-col), +`cython-lint`, `cmake-format`, `shfmt`/`shellcheck`, `markdownlint-cli2`. + +### clang-tidy (separate from pre-commit) + +```bash +uv run --no-project --with "clang-tidy==21.1.1" \ + python tests/lint/clang_tidy_precommit.py \ + --build-dir=build-pre-commit \ + --jobs=$(sysctl -n hw.ncpu) \ + ./src/ ./include ./tests +``` + Review Comment:  The `clang-tidy` command uses `sysctl -n hw.ncpu` to determine the number of parallel jobs, which is macOS-specific and will fail on Linux. It would be helpful to add a note explaining the Linux alternative (`nproc`), similar to the one already present in `SKILL.md`. ```suggestion > On Linux, replace $(sysctl -n hw.ncpu) with $(nproc). ``` -- 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]
