You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "junrushao (via GitHub)" <gi...@apache.org> on 2026/02/21 08:14:41 UTC
[PR] Add CLAUDE.md and dev server launch config [tvm-ffi]
junrushao opened a new pull request, #468:
URL: https://github.com/apache/tvm-ffi/pull/468
## Summary
- Add `CLAUDE.md` with project overview, build/test/lint instructions, code conventions, and architecture notes for Claude Code
- Add `.claude/launch.json` with Sphinx autobuild dev server configuration (port 8000)
## Test plan
- [x] Pre-commit hooks pass (ASF header, markdownlint, etc.)
- [ ] Verify `CLAUDE.md` content is accurate and useful for Claude Code sessions
- [ ] Verify `.claude/launch.json` correctly starts the docs dev server
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] feat: add CLAUDE.md and dev server launch config [tvm-ffi]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen merged PR #468:
URL: https://github.com/apache/tvm-ffi/pull/468
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] Add CLAUDE.md and dev server launch config [tvm-ffi]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #468:
URL: https://github.com/apache/tvm-ffi/pull/468#discussion_r2835975172
##########
CLAUDE.md:
##########
@@ -0,0 +1,178 @@
+<!--- 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. -->
+
+# CLAUDE.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.
+
+### 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) \
Review Comment:

The `sysctl -n hw.ncpu` command is macOS-specific. For better portability across Linux and macOS, consider using a more universal way to determine the number of CPU cores.
```suggestion
--jobs=$(nproc 2>/dev/null || sysctl -n hw.ncpu) \
```
##########
CLAUDE.md:
##########
@@ -0,0 +1,178 @@
+<!--- 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. -->
+
+# CLAUDE.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.
+
+### 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" \
Review Comment:

The version `21.1.1` for `clang-tidy` seems incorrect as the current stable LLVM version is 19. Please verify if this is a typo or a specific requirement for this project.
##########
CLAUDE.md:
##########
@@ -0,0 +1,178 @@
+<!--- 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. -->
+
+# CLAUDE.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.
+
+### 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
+```
+
+## Code conventions
+
+### C++
+
+- Source files: `.cc` (not `.cpp`). Headers: `.h`.
+- Style: Google (via clang-format), 100-col limit, pointer-left (`int* ptr`).
+- Namespaces: `namespace tvm { namespace ffi { ... } }` (no C++17 nested form).
+- Header guards: `#ifndef TVM_FFI_<PATH>_H_`.
+- Object pattern: `FooObj` (data) + `Foo` (ref wrapper extending `ObjectRef`).
+ - `TVM_FFI_DECLARE_OBJECT_INFO("key", FooObj, ParentObj)` in the Obj class.
+ - `TVM_FFI_DEFINE_OBJECT_REF_METHODS(Foo, ParentRef, FooObj)` in the Ref class.
+- Errors: `TVM_FFI_THROW(ErrorType) << "message"`.
+- Doc comments: Doxygen (`/*! \brief ... */`).
+- Every file needs an Apache 2.0 license header.
+
+### Python
+
+- `from __future__ import annotations` at the top of every file.
+- Style: `ruff` (100-col, double quotes, Google docstrings).
+- Register objects: `@register_object("type.Key")`.
+- Register functions: `register_global_func("name", fn)`.
+
+### Commit messages
+
+Tag-based style: `[FEAT]`, `[FIX]`, `[ERROR]`, `[TEST]`, `[CORE]`, `[EXTRA]`, etc.
+Conventional style (`feat:`, `fix:`, `doc:`) is also used. Include PR number.
+
+## Key architecture concepts
+
+- **Any/AnyView**: Type-erased value containers. `AnyView` is non-owning, `Any` owns.
+- **Object system**: Ref-counted heap objects. `ObjectObj` holds data, `Object` is the
+ ref wrapper. Created via `make_object<T>(args...)`.
+- **Function**: Type-erased callable with packed calling convention
+ `(const AnyView* args, int32_t num_args, Any* rv)`.
+- **Global registry**: Functions registered by string name, accessible cross-language
+ via `register_global_func`/`get_global_func`.
+- **Containers**: `Array<T>` (immutable), `List<T>` (mutable), `Map<K,V>` (immutable),
+ `Dict` (mutable), `String`, `Tensor`, `Shape`, `Tuple`, `Variant<T...>`.
+- **Reflection**: `ObjectDef<T>` builder with `def_field`/`def_method`. Exposed to
+ Python as `tvm_ffi.dataclasses.c_class`.
+- **Module system**: `load_module("path.so")` wraps shared libraries, exposing
+ functions via `__tvm_ffi_<name>` symbol prefix.
+
+## CI
+
+Runs on: Linux x86_64 + aarch64, macOS arm64, Windows AMD64.
+Jobs: lint -> clang-tidy (if C++ changed) -> doc build -> test (C++, Python, Rust).
+
+## Further reading
+
+The `docs/` directory contains the full Sphinx documentation site, including:
+
+- `docs/concepts/` — design docs (ABI overview, Any, Object/Class, Tensor, Function, etc.)
Review Comment:

To maintain consistency with `docs/dev/doc_build.rst` and the new `.claude/launch.json`, consider adding the `--ignore` flag to the `sphinx-autobuild` command. This prevents potential infinite build loops when generated documentation files are updated.
```suggestion
uv run --group docs sphinx-autobuild docs docs/_build/html --ignore docs/reference/cpp/generated # live reload
```
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] Add CLAUDE.md and dev server launch config [tvm-ffi]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #468:
URL: https://github.com/apache/tvm-ffi/pull/468#issuecomment-3938436063
## Summary of Changes
Hello @junrushao, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the developer experience and documentation for the TVM FFI project. It introduces a detailed `CLAUDE.md` file to serve as a central resource for new contributors and existing developers, covering essential aspects from project structure to coding standards. Additionally, it provides a convenient VS Code launch configuration to streamline the process of running the documentation development server.
### Highlights
* **Documentation**: A new `CLAUDE.md` file was added, providing a comprehensive overview of the project, including build, test, lint instructions, code conventions, and architectural concepts for TVM FFI.
* **Developer Experience**: A new VS Code launch configuration (`.claude/launch.json`) was introduced to simplify starting the Sphinx autobuild development server for documentation.
🧠**New Feature in Public Preview:** You can now enable **Memory** to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
<details>
<summary><b>Changelog</b></summary>
* **.claude/launch.json**
* Added a new VS Code launch configuration for the documentation development server.
* Configured `uv run` with `sphinx-autobuild` to serve docs on port 8000.
* **CLAUDE.md**
* Added a new Markdown file containing a project overview for TVM FFI.
* Included detailed instructions for building, testing, and linting the project.
* Documented C++ and Python code conventions.
* Outlined key architectural concepts of the TVM FFI.
* Provided information on CI and documentation build processes.
</details>
<details>
<summary><b>Activity</b></summary>
* The author verified that pre-commit hooks passed.
* The author plans to verify the accuracy and usefulness of `CLAUDE.md` content for Claude Code sessions.
* The author plans to verify that the `.claude/launch.json` correctly starts the docs dev server.
* The pull request was generated using Claude Code.
</details>
<details>
<summary><b>Using Gemini Code Assist</b></summary>
<br>
The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
<b>Invoking Gemini</b>
You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
Feature | Command | Description
--- | --- | ---
Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help | `/gemini help` | Displays a list of available commands.
<b>Customization</b>
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
<b>Limitations & Feedback</b>
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
<b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b>
</details>
[^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org