tinygnn 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. tinygnn-0.1.2/CITATION.cff +39 -0
  2. tinygnn-0.1.2/CMakeLists.txt +92 -0
  3. tinygnn-0.1.2/CONTRIBUTING.md +142 -0
  4. tinygnn-0.1.2/Doxyfile +89 -0
  5. tinygnn-0.1.2/LICENSE +21 -0
  6. tinygnn-0.1.2/MANIFEST.in +40 -0
  7. tinygnn-0.1.2/PKG-INFO +1374 -0
  8. tinygnn-0.1.2/README.md +1323 -0
  9. tinygnn-0.1.2/benchmarks/bench_fusion.cpp +534 -0
  10. tinygnn-0.1.2/benchmarks/bench_parallel.cpp +254 -0
  11. tinygnn-0.1.2/benchmarks/massif_gat_fused.cpp +90 -0
  12. tinygnn-0.1.2/benchmarks/massif_gat_unfused.cpp +137 -0
  13. tinygnn-0.1.2/docs/Makefile +20 -0
  14. tinygnn-0.1.2/docs/benchmarks.rst +94 -0
  15. tinygnn-0.1.2/docs/conf.py +82 -0
  16. tinygnn-0.1.2/docs/contributing.rst +5 -0
  17. tinygnn-0.1.2/docs/cpp_api.rst +87 -0
  18. tinygnn-0.1.2/docs/index.rst +36 -0
  19. tinygnn-0.1.2/docs/installation.rst +67 -0
  20. tinygnn-0.1.2/docs/make.bat +35 -0
  21. tinygnn-0.1.2/docs/python_api.rst +335 -0
  22. tinygnn-0.1.2/docs/quickstart.rst +91 -0
  23. tinygnn-0.1.2/include/tinygnn/graph_loader.hpp +88 -0
  24. tinygnn-0.1.2/include/tinygnn/layers.hpp +445 -0
  25. tinygnn-0.1.2/include/tinygnn/model.hpp +166 -0
  26. tinygnn-0.1.2/include/tinygnn/ops.hpp +288 -0
  27. tinygnn-0.1.2/include/tinygnn/tensor.hpp +96 -0
  28. tinygnn-0.1.2/pyproject.toml +95 -0
  29. tinygnn-0.1.2/python/tinygnn/__init__.py +113 -0
  30. tinygnn-0.1.2/python/tinygnn_ext.cpp +432 -0
  31. tinygnn-0.1.2/scripts/build_python.py +70 -0
  32. tinygnn-0.1.2/scripts/fetch_datasets.py +271 -0
  33. tinygnn-0.1.2/scripts/install_wsl_tools.sh +26 -0
  34. tinygnn-0.1.2/scripts/plot_scaling.py +131 -0
  35. tinygnn-0.1.2/scripts/run_massif_phase9.sh +66 -0
  36. tinygnn-0.1.2/scripts/sanitizers.sh +169 -0
  37. tinygnn-0.1.2/scripts/train_cora.py +368 -0
  38. tinygnn-0.1.2/scripts/valgrind_all.sh +486 -0
  39. tinygnn-0.1.2/scripts/validate_cora.py +378 -0
  40. tinygnn-0.1.2/setup.cfg +4 -0
  41. tinygnn-0.1.2/setup.py +143 -0
  42. tinygnn-0.1.2/src/graph_loader.cpp +328 -0
  43. tinygnn-0.1.2/src/layers.cpp +1086 -0
  44. tinygnn-0.1.2/src/model.cpp +441 -0
  45. tinygnn-0.1.2/src/ops.cpp +616 -0
  46. tinygnn-0.1.2/src/tensor.cpp +176 -0
  47. tinygnn-0.1.2/tests/test_activations.cpp +1271 -0
  48. tinygnn-0.1.2/tests/test_e2e.cpp +899 -0
  49. tinygnn-0.1.2/tests/test_gat.cpp +853 -0
  50. tinygnn-0.1.2/tests/test_gcn.cpp +1464 -0
  51. tinygnn-0.1.2/tests/test_graph_loader.cpp +1728 -0
  52. tinygnn-0.1.2/tests/test_graphsage.cpp +1244 -0
  53. tinygnn-0.1.2/tests/test_matmul.cpp +954 -0
  54. tinygnn-0.1.2/tests/test_python_bindings.py +615 -0
  55. tinygnn-0.1.2/tests/test_spmm.cpp +1137 -0
  56. tinygnn-0.1.2/tests/test_tensor.cpp +524 -0
  57. tinygnn-0.1.2/tinygnn.egg-info/PKG-INFO +1374 -0
  58. tinygnn-0.1.2/tinygnn.egg-info/SOURCES.txt +60 -0
  59. tinygnn-0.1.2/tinygnn.egg-info/dependency_links.txt +1 -0
  60. tinygnn-0.1.2/tinygnn.egg-info/not-zip-safe +1 -0
  61. tinygnn-0.1.2/tinygnn.egg-info/requires.txt +21 -0
  62. tinygnn-0.1.2/tinygnn.egg-info/top_level.txt +2 -0
@@ -0,0 +1,39 @@
1
+ # This CITATION.cff file was generated with cffinit.
2
+ # Visit https://bit.ly/cffinit to generate yours today!
3
+
4
+ cff-version: 1.2.0
5
+ title: "TinyGNN: A Zero-Dependency C++ Inference Engine for Sparse Graph Neural Networks"
6
+ message: >-
7
+ If you use this software, please cite it using the
8
+ metadata from this file.
9
+ type: software
10
+ authors:
11
+ - given-names: Jai Ansh Singh
12
+ family-names: Bindra
13
+ affiliation: JBAC EdTech
14
+ - given-names: Anubhav
15
+ family-names: Choudhery
16
+ affiliation: JBAC EdTech
17
+ repository-code: "https://github.com/JaiAnshSB/TinyGNN"
18
+ url: "https://github.com/JaiAnshSB/TinyGNN"
19
+ abstract: >-
20
+ TinyGNN is a dependency-free C++17 inference engine optimized for
21
+ Sparse Graph Neural Networks (GCN, GraphSAGE, GAT). It features
22
+ hybrid Dense/SparseCSR tensor storage, AVX2 SIMD intrinsics,
23
+ OpenMP thread parallelism, operator fusion for GAT and GraphSAGE
24
+ kernels, and Python bindings via pybind11 with zero-copy NumPy,
25
+ SciPy, and PyTorch interoperability.
26
+ keywords:
27
+ - graph neural networks
28
+ - sparse inference
29
+ - GCN
30
+ - GraphSAGE
31
+ - GAT
32
+ - C++17
33
+ - pybind11
34
+ - SIMD
35
+ - operator fusion
36
+ - zero-dependency
37
+ license: MIT
38
+ version: 0.1.0
39
+ date-released: "2026-02-28"
@@ -0,0 +1,92 @@
1
+ cmake_minimum_required(VERSION 3.16)
2
+ project(TinyGNN VERSION 0.1.0 LANGUAGES CXX)
3
+
4
+ # ── C++17 standard ──────────────────────────────────────────────────────────
5
+ set(CMAKE_CXX_STANDARD 17)
6
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
7
+ set(CMAKE_CXX_EXTENSIONS OFF)
8
+
9
+ # ── Compiler warnings ──────────────────────────────────────────────────────
10
+ if(MSVC)
11
+ add_compile_options(/W4)
12
+ else()
13
+ add_compile_options(-Wall -Wextra -Wpedantic)
14
+ # Static link on MinGW to avoid ld dynamic linking issues
15
+ if(MINGW)
16
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
17
+ endif()
18
+ endif()
19
+
20
+ # ── Core library ────────────────────────────────────────────────────────────
21
+ add_library(tinygnn_core
22
+ src/tensor.cpp
23
+ src/graph_loader.cpp
24
+ src/ops.cpp
25
+ src/layers.cpp
26
+ src/model.cpp
27
+ )
28
+
29
+ target_include_directories(tinygnn_core PUBLIC
30
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
31
+ )
32
+
33
+ # ── OpenMP (Phase 8) ───────────────────────────────────────────────────────
34
+ find_package(OpenMP)
35
+ if(OpenMP_CXX_FOUND)
36
+ target_link_libraries(tinygnn_core PUBLIC OpenMP::OpenMP_CXX)
37
+ endif()
38
+
39
+ # ── AVX2 + FMA intrinsics (Phase 8) ────────────────────────────────────────
40
+ include(CheckCXXCompilerFlag)
41
+ check_cxx_compiler_flag("-mavx2" COMPILER_SUPPORTS_AVX2)
42
+ check_cxx_compiler_flag("-mfma" COMPILER_SUPPORTS_FMA)
43
+ if(COMPILER_SUPPORTS_AVX2 AND COMPILER_SUPPORTS_FMA)
44
+ target_compile_options(tinygnn_core PRIVATE -mavx2 -mfma)
45
+ endif()
46
+
47
+ # ── Tests ───────────────────────────────────────────────────────────────────
48
+ enable_testing()
49
+
50
+ add_executable(test_tensor tests/test_tensor.cpp)
51
+ target_link_libraries(test_tensor PRIVATE tinygnn_core)
52
+ add_test(NAME TensorTests COMMAND test_tensor)
53
+
54
+ add_executable(test_graph_loader tests/test_graph_loader.cpp)
55
+ target_link_libraries(test_graph_loader PRIVATE tinygnn_core)
56
+ add_test(NAME GraphLoaderTests COMMAND test_graph_loader)
57
+
58
+ add_executable(test_matmul tests/test_matmul.cpp)
59
+ target_link_libraries(test_matmul PRIVATE tinygnn_core)
60
+ add_test(NAME MatmulTests COMMAND test_matmul)
61
+
62
+ add_executable(test_spmm tests/test_spmm.cpp)
63
+ target_link_libraries(test_spmm PRIVATE tinygnn_core)
64
+ add_test(NAME SpmmTests COMMAND test_spmm)
65
+
66
+ add_executable(test_activations tests/test_activations.cpp)
67
+ target_link_libraries(test_activations PRIVATE tinygnn_core)
68
+ add_test(NAME ActivationsTests COMMAND test_activations)
69
+
70
+ add_executable(test_gcn tests/test_gcn.cpp)
71
+ target_link_libraries(test_gcn PRIVATE tinygnn_core)
72
+ add_test(NAME GCNTests COMMAND test_gcn)
73
+
74
+ add_executable(test_graphsage tests/test_graphsage.cpp)
75
+ target_link_libraries(test_graphsage PRIVATE tinygnn_core)
76
+ add_test(NAME GraphSAGETests COMMAND test_graphsage)
77
+
78
+ add_executable(test_gat tests/test_gat.cpp)
79
+ target_link_libraries(test_gat PRIVATE tinygnn_core)
80
+ add_test(NAME GATTests COMMAND test_gat)
81
+
82
+ add_executable(test_e2e tests/test_e2e.cpp)
83
+ target_link_libraries(test_e2e PRIVATE tinygnn_core)
84
+ add_test(NAME E2ETests COMMAND test_e2e)
85
+
86
+ # ── Benchmark (Phase 8) ────────────────────────────────────────────────────
87
+ add_executable(bench_parallel benchmarks/bench_parallel.cpp)
88
+ target_link_libraries(bench_parallel PRIVATE tinygnn_core)
89
+
90
+ # ── Benchmark (Phase 9: Operator Fusion) ──────────────────────────────────
91
+ add_executable(bench_fusion benchmarks/bench_fusion.cpp)
92
+ target_link_libraries(bench_fusion PRIVATE tinygnn_core)
@@ -0,0 +1,142 @@
1
+ # Contributing to TinyGNN
2
+
3
+ Thank you for your interest in contributing to TinyGNN! This document provides guidelines and information for contributors.
4
+
5
+ ## Authors
6
+
7
+ **Jai Ansh Singh Bindra and Anubhav Choudhery (under JBAC EdTech)**
8
+
9
+ ## Getting Started
10
+
11
+ ### Prerequisites
12
+
13
+ - **C++17 compiler**: GCC 8+, Clang 7+, or MSVC 2019+
14
+ - **CMake 3.16+**
15
+ - **Python 3.8+** (for Python bindings)
16
+ - **pybind11 ≥ 2.11** (for Python bindings)
17
+
18
+ ### Setting Up the Development Environment
19
+
20
+ ```bash
21
+ # Clone the repository
22
+ git clone https://github.com/JaiAnshSB/TinyGNN.git
23
+ cd TinyGNN
24
+
25
+ # Create a virtual environment
26
+ python -m venv .venv
27
+ source .venv/bin/activate # Linux/macOS
28
+ # .venv\Scripts\activate # Windows
29
+
30
+ # Install development dependencies
31
+ pip install -e ".[dev]"
32
+
33
+ # Build and test C++
34
+ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
35
+ cmake --build build --parallel
36
+ ctest --test-dir build --output-on-failure
37
+
38
+ # Run Python tests
39
+ python -m pytest tests/test_python_bindings.py -v
40
+ ```
41
+
42
+ ## Development Workflow
43
+
44
+ ### Code Style
45
+
46
+ **C++ (backend)**:
47
+ - C++17 standard
48
+ - 4-space indentation
49
+ - `snake_case` for functions and variables
50
+ - `PascalCase` for types and classes
51
+ - Comprehensive documentation comments (Doxygen-style)
52
+ - All public functions must have `@throws` documentation
53
+
54
+ **Python (frontend)**:
55
+ - Follow PEP 8
56
+ - Type hints where practical
57
+ - Docstrings for all public functions
58
+
59
+ ### Adding a New Operation
60
+
61
+ 1. **Declare** in the appropriate header (`include/tinygnn/ops.hpp` or `layers.hpp`)
62
+ 2. **Implement** in the corresponding source (`src/ops.cpp` or `src/layers.cpp`)
63
+ 3. **Bind** in `python/tinygnn_ext.cpp`
64
+ 4. **Export** in `python/tinygnn/__init__.py`
65
+ 5. **Test** with both C++ assertions and Python pytest
66
+
67
+ ### Running Tests
68
+
69
+ ```bash
70
+ # C++ tests (all 9 test suites, 18,000+ assertions)
71
+ cmake --build build --parallel
72
+ ctest --test-dir build --output-on-failure
73
+
74
+ # Python tests (49 tests)
75
+ python -m pytest tests/test_python_bindings.py -v
76
+
77
+ # Memory safety (Linux/WSL only)
78
+ bash scripts/sanitizers.sh # ASan + UBSan
79
+ bash scripts/valgrind_all.sh # Memcheck + Helgrind
80
+ ```
81
+
82
+ ### Building Documentation
83
+
84
+ ```bash
85
+ # C++ docs (Doxygen)
86
+ doxygen Doxyfile
87
+ # Output: docs/doxygen/html/index.html
88
+
89
+ # Python docs (Sphinx)
90
+ pip install sphinx sphinx-rtd-theme breathe
91
+ cd docs && make html
92
+ # Output: docs/_build/html/index.html
93
+ ```
94
+
95
+ ## Pull Request Guidelines
96
+
97
+ 1. **Branch from `main`** and target `main` for your PR
98
+ 2. **Keep commits focused** — one logical change per commit
99
+ 3. **Write descriptive commit messages** following the format:
100
+ ```
101
+ Phase N: Brief description of change
102
+
103
+ Detailed explanation of what changed and why.
104
+ Include test results where applicable.
105
+ ```
106
+ 4. **All existing tests must pass** — CI will verify this automatically
107
+ 5. **Add tests for new functionality** — aim for comprehensive coverage
108
+ 6. **Update documentation** when adding public API surface
109
+
110
+ ## Architecture Overview
111
+
112
+ ```
113
+ include/tinygnn/ → C++ public headers (tensor, ops, layers, model)
114
+ src/ → C++ implementations
115
+ python/ → pybind11 bindings + Python package
116
+ tests/ → C++ test suites + Python pytest
117
+ benchmarks/ → Performance benchmark programs
118
+ scripts/ → Build helpers, training, validation
119
+ docs/ → Sphinx + Doxygen documentation
120
+ .github/workflows/ → GitHub Actions CI/CD
121
+ ```
122
+
123
+ ### Design Principles
124
+
125
+ - **Zero dependencies** — no Eigen, BLAS, Boost, or external libraries
126
+ - **Fail-fast validation** — descriptive exceptions for all invalid inputs
127
+ - **In-place where possible** — minimize memory allocations
128
+ - **Cache-aware** — (i,k,j) loop order, AVX2 SIMD, OpenMP parallelism
129
+ - **Operator fusion** — fused GAT/SAGE kernels reduce memory bandwidth
130
+
131
+ ## Reporting Issues
132
+
133
+ When reporting bugs, please include:
134
+ - Operating system and compiler version
135
+ - Python version (if applicable)
136
+ - Steps to reproduce
137
+ - Expected vs. actual behavior
138
+ - Relevant error messages or stack traces
139
+
140
+ ## License
141
+
142
+ By contributing to TinyGNN, you agree that your contributions will be licensed under the MIT License.
tinygnn-0.1.2/Doxyfile ADDED
@@ -0,0 +1,89 @@
1
+ # =============================================================================
2
+ # TinyGNN — Doxygen Configuration
3
+ # Doxyfile
4
+ #
5
+ # Generates C++ API documentation from the annotated header files.
6
+ #
7
+ # Usage:
8
+ # doxygen Doxyfile
9
+ #
10
+ # Output: docs/doxygen/html/index.html
11
+ # =============================================================================
12
+
13
+ # ── Project metadata ─────────────────────────────────────────────────────────
14
+ PROJECT_NAME = "TinyGNN"
15
+ PROJECT_NUMBER = "0.1.0"
16
+ PROJECT_BRIEF = "A zero-dependency C++17 inference engine for Sparse Graph Neural Networks"
17
+ PROJECT_LOGO =
18
+
19
+ # ── Input ────────────────────────────────────────────────────────────────────
20
+ INPUT = include/tinygnn \
21
+ src
22
+ INPUT_ENCODING = UTF-8
23
+ FILE_PATTERNS = *.hpp *.cpp
24
+ RECURSIVE = YES
25
+
26
+ # ── Output ───────────────────────────────────────────────────────────────────
27
+ OUTPUT_DIRECTORY = docs/doxygen
28
+ GENERATE_HTML = YES
29
+ HTML_OUTPUT = html
30
+ HTML_THEME =
31
+ GENERATE_LATEX = NO
32
+ GENERATE_XML = YES
33
+ XML_OUTPUT = xml
34
+
35
+ # ── Extraction ───────────────────────────────────────────────────────────────
36
+ EXTRACT_ALL = YES
37
+ EXTRACT_PRIVATE = NO
38
+ EXTRACT_STATIC = YES
39
+ EXTRACT_LOCAL_CLASSES = YES
40
+ EXTRACT_ANON_NSPACES = NO
41
+
42
+ # ── Source browsing ──────────────────────────────────────────────────────────
43
+ SOURCE_BROWSER = YES
44
+ INLINE_SOURCES = NO
45
+ STRIP_CODE_COMMENTS = NO
46
+ REFERENCED_BY_RELATION = YES
47
+ REFERENCES_RELATION = YES
48
+
49
+ # ── Namespaces ───────────────────────────────────────────────────────────────
50
+ HIDE_UNDOC_MEMBERS = NO
51
+ HIDE_UNDOC_CLASSES = NO
52
+ SHOW_NAMESPACES = YES
53
+
54
+ # ── Graphs ───────────────────────────────────────────────────────────────────
55
+ HAVE_DOT = YES
56
+ DOT_IMAGE_FORMAT = svg
57
+ INTERACTIVE_SVG = YES
58
+ CLASS_DIAGRAMS = YES
59
+ COLLABORATION_GRAPH = YES
60
+ INCLUDE_GRAPH = YES
61
+ INCLUDED_BY_GRAPH = YES
62
+ CALL_GRAPH = NO
63
+ CALLER_GRAPH = NO
64
+ GRAPHICAL_HIERARCHY = YES
65
+ DIRECTORY_GRAPH = YES
66
+ DOT_GRAPH_MAX_NODES = 100
67
+ MAX_DOT_GRAPH_DEPTH = 0
68
+
69
+ # ── Preprocessing ────────────────────────────────────────────────────────────
70
+ ENABLE_PREPROCESSING = YES
71
+ MACRO_EXPANSION = YES
72
+ EXPAND_ONLY_PREDEF = NO
73
+ PREDEFINED = __AVX2__ \
74
+ _OPENMP
75
+
76
+ # ── Warnings ─────────────────────────────────────────────────────────────────
77
+ WARNINGS = YES
78
+ WARN_IF_UNDOCUMENTED = YES
79
+ WARN_IF_DOC_ERROR = YES
80
+ WARN_NO_PARAMDOC = YES
81
+
82
+ # ── Styling ──────────────────────────────────────────────────────────────────
83
+ GENERATE_TREEVIEW = YES
84
+ DISABLE_INDEX = NO
85
+ FULL_SIDEBAR = NO
86
+ HTML_COLORSTYLE = LIGHT
87
+ HTML_DYNAMIC_MENUS = YES
88
+ HTML_DYNAMIC_SECTIONS = YES
89
+ SEARCHENGINE = YES
tinygnn-0.1.2/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Jai Ansh Singh Bindra and Anubhav Choudhery (under JBAC EdTech)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Include C++ source and headers for source distributions
2
+ include CMakeLists.txt
3
+ include README.md
4
+ include LICENSE
5
+ include pyproject.toml
6
+ include setup.py
7
+
8
+ # C++ sources
9
+ recursive-include include *.hpp
10
+ recursive-include src *.cpp
11
+
12
+ # pybind11 bindings
13
+ include python/tinygnn_ext.cpp
14
+ recursive-include python/tinygnn *.py
15
+
16
+ # Benchmarks (for reference, not required for build)
17
+ recursive-include benchmarks *.cpp
18
+
19
+ # Scripts
20
+ recursive-include scripts *.py *.sh
21
+
22
+ # Tests
23
+ recursive-include tests *.cpp *.py
24
+
25
+ # Documentation
26
+ recursive-include docs *
27
+ include Doxyfile
28
+ include CITATION.cff
29
+ include CONTRIBUTING.md
30
+
31
+ # Exclude build artifacts
32
+ global-exclude *.o *.obj *.exe *.dll *.so *.dylib *.pyd
33
+ global-exclude __pycache__ *.pyc
34
+ prune build
35
+ prune build-cpp
36
+ prune .venv
37
+ prune venv
38
+ prune datasets
39
+ prune weights
40
+ prune .git