tensorstudio 0.0.1a0__tar.gz → 0.1.0__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 (100) hide show
  1. tensorstudio-0.1.0/.github/workflows/ci.yml +31 -0
  2. tensorstudio-0.1.0/.github/workflows/publish.yml +39 -0
  3. tensorstudio-0.1.0/.github/workflows/wheels.yml +45 -0
  4. tensorstudio-0.1.0/.gitignore +21 -0
  5. tensorstudio-0.1.0/.pre-commit-config.yaml +13 -0
  6. tensorstudio-0.1.0/CHANGELOG.md +9 -0
  7. tensorstudio-0.1.0/CMakeLists.txt +51 -0
  8. tensorstudio-0.1.0/CONTRIBUTING.md +30 -0
  9. tensorstudio-0.1.0/LICENSE +21 -0
  10. tensorstudio-0.1.0/PKG-INFO +188 -0
  11. tensorstudio-0.1.0/README.md +130 -0
  12. tensorstudio-0.1.0/SECURITY.md +21 -0
  13. tensorstudio-0.1.0/benchmarks/bench_matmul.py +28 -0
  14. tensorstudio-0.1.0/benchmarks/bench_tensor_ops.py +31 -0
  15. tensorstudio-0.1.0/docs/Autograde/index.md +104 -0
  16. tensorstudio-0.1.0/docs/Benchmarks/index.md +53 -0
  17. tensorstudio-0.1.0/docs/Hardware/cpu-backend.md +39 -0
  18. tensorstudio-0.1.0/docs/Neural Networks/modules.md +102 -0
  19. tensorstudio-0.1.0/docs/Neural Networks/training.md +64 -0
  20. tensorstudio-0.1.0/docs/Roadmap/index.md +55 -0
  21. tensorstudio-0.1.0/docs/Usage/numpy-interop.md +55 -0
  22. tensorstudio-0.1.0/docs/Usage/serialization.md +42 -0
  23. tensorstudio-0.1.0/docs/Usage/tensors.md +133 -0
  24. tensorstudio-0.1.0/docs/api.md +164 -0
  25. tensorstudio-0.1.0/docs/development.md +120 -0
  26. tensorstudio-0.1.0/docs/index.md +55 -0
  27. tensorstudio-0.1.0/docs/publishing.md +101 -0
  28. tensorstudio-0.1.0/docs/quickstart.md +115 -0
  29. tensorstudio-0.1.0/examples/basic_tensor_ops.py +17 -0
  30. tensorstudio-0.1.0/examples/linear_regression.py +29 -0
  31. tensorstudio-0.1.0/examples/save_load_model.py +22 -0
  32. tensorstudio-0.1.0/examples/tiny_mlp.py +28 -0
  33. tensorstudio-0.1.0/include/tensorstudio/autograd.hpp +15 -0
  34. tensorstudio-0.1.0/include/tensorstudio/device.hpp +25 -0
  35. tensorstudio-0.1.0/include/tensorstudio/dtype.hpp +23 -0
  36. tensorstudio-0.1.0/include/tensorstudio/errors.hpp +33 -0
  37. tensorstudio-0.1.0/include/tensorstudio/module.hpp +9 -0
  38. tensorstudio-0.1.0/include/tensorstudio/ops.hpp +37 -0
  39. tensorstudio-0.1.0/include/tensorstudio/optim.hpp +9 -0
  40. tensorstudio-0.1.0/include/tensorstudio/random.hpp +11 -0
  41. tensorstudio-0.1.0/include/tensorstudio/serialization.hpp +9 -0
  42. tensorstudio-0.1.0/include/tensorstudio/shape.hpp +26 -0
  43. tensorstudio-0.1.0/include/tensorstudio/storage.hpp +27 -0
  44. tensorstudio-0.1.0/include/tensorstudio/tensor.hpp +92 -0
  45. tensorstudio-0.1.0/include/tensorstudio/version.hpp +7 -0
  46. tensorstudio-0.1.0/mkdocs.yml +33 -0
  47. tensorstudio-0.1.0/pyproject.toml +82 -0
  48. tensorstudio-0.1.0/python/tensorstudio/_C.pyi +81 -0
  49. tensorstudio-0.1.0/python/tensorstudio/__init__.py +24 -0
  50. tensorstudio-0.1.0/python/tensorstudio/_version.py +5 -0
  51. tensorstudio-0.1.0/python/tensorstudio/autograd.py +15 -0
  52. tensorstudio-0.1.0/python/tensorstudio/data/__init__.py +8 -0
  53. tensorstudio-0.1.0/python/tensorstudio/data/dataloader.py +38 -0
  54. tensorstudio-0.1.0/python/tensorstudio/data/dataset.py +34 -0
  55. tensorstudio-0.1.0/python/tensorstudio/errors.py +19 -0
  56. tensorstudio-0.1.0/python/tensorstudio/nn/__init__.py +22 -0
  57. tensorstudio-0.1.0/python/tensorstudio/nn/functional.py +25 -0
  58. tensorstudio-0.1.0/python/tensorstudio/nn/losses.py +18 -0
  59. tensorstudio-0.1.0/python/tensorstudio/nn/modules.py +150 -0
  60. tensorstudio-0.1.0/python/tensorstudio/ops.py +97 -0
  61. tensorstudio-0.1.0/python/tensorstudio/optim/__init__.py +8 -0
  62. tensorstudio-0.1.0/python/tensorstudio/optim/adam.py +53 -0
  63. tensorstudio-0.1.0/python/tensorstudio/optim/sgd.py +31 -0
  64. tensorstudio-0.1.0/python/tensorstudio/py.typed +1 -0
  65. tensorstudio-0.1.0/python/tensorstudio/serialization.py +34 -0
  66. tensorstudio-0.1.0/python/tensorstudio/tensor.py +69 -0
  67. tensorstudio-0.1.0/python/tensorstudio/typing.py +12 -0
  68. tensorstudio-0.1.0/src/bindings/bind_autograd.cpp +23 -0
  69. tensorstudio-0.1.0/src/bindings/bind_nn.cpp +11 -0
  70. tensorstudio-0.1.0/src/bindings/bind_ops.cpp +29 -0
  71. tensorstudio-0.1.0/src/bindings/bind_optim.cpp +11 -0
  72. tensorstudio-0.1.0/src/bindings/bind_tensor.cpp +383 -0
  73. tensorstudio-0.1.0/src/bindings/bindings.cpp +25 -0
  74. tensorstudio-0.1.0/src/bindings/bindings.hpp +27 -0
  75. tensorstudio-0.1.0/src/core/autograd.cpp +128 -0
  76. tensorstudio-0.1.0/src/core/device.cpp +21 -0
  77. tensorstudio-0.1.0/src/core/dtype.cpp +90 -0
  78. tensorstudio-0.1.0/src/core/errors.cpp +15 -0
  79. tensorstudio-0.1.0/src/core/module.cpp +9 -0
  80. tensorstudio-0.1.0/src/core/ops.cpp +448 -0
  81. tensorstudio-0.1.0/src/core/optim.cpp +9 -0
  82. tensorstudio-0.1.0/src/core/random.cpp +18 -0
  83. tensorstudio-0.1.0/src/core/serialization.cpp +9 -0
  84. tensorstudio-0.1.0/src/core/shape.cpp +153 -0
  85. tensorstudio-0.1.0/src/core/storage.cpp +29 -0
  86. tensorstudio-0.1.0/src/core/tensor.cpp +307 -0
  87. tensorstudio-0.1.0/tests/test_autograd.py +61 -0
  88. tensorstudio-0.1.0/tests/test_import.py +10 -0
  89. tensorstudio-0.1.0/tests/test_nn.py +41 -0
  90. tensorstudio-0.1.0/tests/test_numpy_interop.py +28 -0
  91. tensorstudio-0.1.0/tests/test_ops.py +45 -0
  92. tensorstudio-0.1.0/tests/test_optim.py +39 -0
  93. tensorstudio-0.1.0/tests/test_serialization.py +26 -0
  94. tensorstudio-0.1.0/tests/test_tensor.py +50 -0
  95. tensorstudio-0.0.1a0/.gitignore +0 -5
  96. tensorstudio-0.0.1a0/PKG-INFO +0 -27
  97. tensorstudio-0.0.1a0/README.md +0 -5
  98. tensorstudio-0.0.1a0/pyproject.toml +0 -22
  99. tensorstudio-0.0.1a0/src/tensorstudio/__init__.py +0 -11
  100. tensorstudio-0.0.1a0/src/tensorstudio/cli.py +0 -8
@@ -0,0 +1,31 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ name: ${{ matrix.os }} py${{ matrix.python-version }}
10
+ runs-on: ${{ matrix.os }}
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os: [ubuntu-latest, macos-latest, windows-latest]
15
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+ - name: Install
23
+ run: |
24
+ python -m pip install -U pip
25
+ python -m pip install -e ".[dev]"
26
+ - name: Ruff
27
+ run: ruff check .
28
+ - name: Mypy
29
+ run: mypy python/tensorstudio
30
+ - name: Tests
31
+ run: pytest
@@ -0,0 +1,39 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.12"
20
+ - name: Build distributions
21
+ run: |
22
+ python -m pip install -U build
23
+ python -m build
24
+ - uses: actions/upload-artifact@v4
25
+ with:
26
+ name: dist
27
+ path: dist/*
28
+
29
+ publish:
30
+ needs: build
31
+ runs-on: ubuntu-latest
32
+ environment: pypi
33
+ steps:
34
+ - uses: actions/download-artifact@v4
35
+ with:
36
+ name: dist
37
+ path: dist
38
+ - name: Publish to PyPI
39
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,45 @@
1
+ name: Wheels
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ build_wheels:
11
+ name: Build wheels on ${{ matrix.os }}
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ os: [ubuntu-latest, macos-latest, windows-latest]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.12"
23
+ - name: Build wheels
24
+ uses: pypa/cibuildwheel@v2.23.3
25
+ - uses: actions/upload-artifact@v4
26
+ with:
27
+ name: wheels-${{ matrix.os }}
28
+ path: wheelhouse/*.whl
29
+
30
+ build_sdist:
31
+ name: Build sdist
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+ - uses: actions/setup-python@v5
36
+ with:
37
+ python-version: "3.12"
38
+ - name: Build sdist
39
+ run: |
40
+ python -m pip install -U build
41
+ python -m build --sdist
42
+ - uses: actions/upload-artifact@v4
43
+ with:
44
+ name: sdist
45
+ path: dist/*.tar.gz
@@ -0,0 +1,21 @@
1
+ build/
2
+ dist/
3
+ *.egg-info/
4
+ __pycache__/
5
+ *.py[cod]
6
+ *.pyd
7
+ *.so
8
+ *.dylib
9
+ .mypy_cache/
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ .coverage
13
+ htmlcov/
14
+ site/
15
+ .venv/
16
+ venv/
17
+ .env
18
+ .env.*
19
+ .idea/
20
+ .vscode/
21
+ *.tsmodel
@@ -0,0 +1,13 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.6.9
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+ - id: ruff-format
8
+ - repo: https://github.com/pre-commit/mirrors-mypy
9
+ rev: v1.11.2
10
+ hooks:
11
+ - id: mypy
12
+ args: [python/tensorstudio]
13
+ additional_dependencies: [numpy>=1.24]
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - Initial experimental release.
6
+ - C++20 CPU tensor core with Python bindings.
7
+ - Basic broadcasting, matrix multiplication, reductions, activations, and views.
8
+ - Reverse-mode autograd for the initial operation set.
9
+ - Python `nn`, `optim`, serialization, examples, tests, docs, and CI workflows.
@@ -0,0 +1,51 @@
1
+ cmake_minimum_required(VERSION 3.18)
2
+
3
+ project(tensorstudio VERSION 0.1.0 LANGUAGES CXX)
4
+
5
+ find_package(pybind11 CONFIG REQUIRED)
6
+
7
+ set(TENSORSTUDIO_CORE_SOURCES
8
+ src/core/tensor.cpp
9
+ src/core/dtype.cpp
10
+ src/core/shape.cpp
11
+ src/core/device.cpp
12
+ src/core/storage.cpp
13
+ src/core/ops.cpp
14
+ src/core/autograd.cpp
15
+ src/core/module.cpp
16
+ src/core/optim.cpp
17
+ src/core/random.cpp
18
+ src/core/serialization.cpp
19
+ src/core/errors.cpp
20
+ )
21
+
22
+ set(TENSORSTUDIO_BINDING_SOURCES
23
+ src/bindings/bindings.cpp
24
+ src/bindings/bind_tensor.cpp
25
+ src/bindings/bind_ops.cpp
26
+ src/bindings/bind_autograd.cpp
27
+ src/bindings/bind_nn.cpp
28
+ src/bindings/bind_optim.cpp
29
+ )
30
+
31
+ pybind11_add_module(_C MODULE
32
+ ${TENSORSTUDIO_CORE_SOURCES}
33
+ ${TENSORSTUDIO_BINDING_SOURCES}
34
+ )
35
+
36
+ target_include_directories(_C PRIVATE include src/bindings)
37
+ target_compile_features(_C PRIVATE cxx_std_20)
38
+
39
+ if(MSVC)
40
+ target_compile_options(_C PRIVATE /W4 /permissive-)
41
+ else()
42
+ target_compile_options(_C PRIVATE -Wall -Wextra -Wpedantic)
43
+ endif()
44
+
45
+ target_compile_definitions(_C PRIVATE TENSORSTUDIO_VERSION="${PROJECT_VERSION}")
46
+
47
+ install(TARGETS _C
48
+ LIBRARY DESTINATION tensorstudio
49
+ RUNTIME DESTINATION tensorstudio
50
+ ARCHIVE DESTINATION tensorstudio
51
+ )
@@ -0,0 +1,30 @@
1
+ # Contributing
2
+
3
+ Thank you for helping improve TensorStudio.
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ python -m pip install -U pip
9
+ python -m pip install -e ".[dev]"
10
+ pre-commit install
11
+ ```
12
+
13
+ ## Checks
14
+
15
+ Run these before opening a pull request:
16
+
17
+ ```bash
18
+ ruff check .
19
+ mypy python/tensorstudio
20
+ pytest
21
+ python -m build
22
+ ```
23
+
24
+ ## Guidelines
25
+
26
+ - Keep C++ tensor operations clear and maintainable.
27
+ - Add tests for user-visible behavior changes.
28
+ - Document limitations honestly.
29
+ - Do not introduce network calls in library code.
30
+ - Do not use `eval` or `exec`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TensorStudio contributors
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,188 @@
1
+ Metadata-Version: 2.2
2
+ Name: tensorstudio
3
+ Version: 0.1.0
4
+ Summary: TensorStudio is a compact C++ tensor and autograd engine with a Python API for learning, experimentation, and lightweight ML workloads.
5
+ Keywords: tensor,autograd,machine-learning,cpp,pybind11
6
+ Author: TensorStudio contributors
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 TensorStudio contributors
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Classifier: Development Status :: 3 - Alpha
30
+ Classifier: Intended Audience :: Developers
31
+ Classifier: Intended Audience :: Education
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Programming Language :: C++
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.10
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Programming Language :: Python :: 3.13
39
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
40
+ Project-URL: Homepage, https://github.com/tensorstudio/tensorstudio
41
+ Project-URL: Repository, https://github.com/tensorstudio/tensorstudio
42
+ Project-URL: Issues, https://github.com/tensorstudio/tensorstudio/issues
43
+ Requires-Python: >=3.10
44
+ Requires-Dist: numpy>=1.24
45
+ Provides-Extra: dev
46
+ Requires-Dist: pytest>=8; extra == "dev"
47
+ Requires-Dist: pytest-cov>=5; extra == "dev"
48
+ Requires-Dist: build>=1.2; extra == "dev"
49
+ Requires-Dist: twine>=5; extra == "dev"
50
+ Requires-Dist: ruff>=0.6; extra == "dev"
51
+ Requires-Dist: mypy>=1.10; extra == "dev"
52
+ Requires-Dist: cibuildwheel>=2.19; extra == "dev"
53
+ Requires-Dist: pre-commit>=3.7; extra == "dev"
54
+ Provides-Extra: docs
55
+ Requires-Dist: mkdocs>=1.6; extra == "docs"
56
+ Requires-Dist: mkdocs-material>=9.5; extra == "docs"
57
+ Description-Content-Type: text/markdown
58
+
59
+ # TensorStudio
60
+
61
+ [![CI](https://github.com/tensorstudio/tensorstudio/actions/workflows/ci.yml/badge.svg)](https://github.com/tensorstudio/tensorstudio/actions/workflows/ci.yml)
62
+ [![Wheels](https://github.com/tensorstudio/tensorstudio/actions/workflows/wheels.yml/badge.svg)](https://github.com/tensorstudio/tensorstudio/actions/workflows/wheels.yml)
63
+ [![PyPI](https://img.shields.io/pypi/v/tensorstudio.svg)](https://pypi.org/project/tensorstudio/)
64
+
65
+ TensorStudio is a compact C++ tensor and autograd engine with a Python API for
66
+ learning, experimentation, and lightweight ML workloads.
67
+
68
+ TensorStudio is experimental v0.1.0 software. It is CPU-only, eager-only, and
69
+ intentionally small enough to read and modify.
70
+
71
+ ## Install
72
+
73
+ From a source checkout:
74
+
75
+ ```bash
76
+ python -m pip install -U pip
77
+ python -m pip install -e ".[dev]"
78
+ ```
79
+
80
+ Build source and wheel distributions:
81
+
82
+ ```bash
83
+ python -m build
84
+ ```
85
+
86
+ ## Quickstart
87
+
88
+ ```python
89
+ import tensorstudio as ts
90
+
91
+ x = ts.tensor([[1.0, 2.0], [3.0, 4.0]])
92
+ y = ts.ones((2, 2))
93
+
94
+ print((x + y).tolist())
95
+ print((x @ y).numpy())
96
+ ```
97
+
98
+ ## Autograd
99
+
100
+ ```python
101
+ import tensorstudio as ts
102
+
103
+ x = ts.tensor([1.0, 2.0, 3.0], requires_grad=True)
104
+ loss = ((x * x).sum())
105
+ loss.backward()
106
+
107
+ print(x.grad.tolist()) # [2.0, 4.0, 6.0]
108
+ ```
109
+
110
+ ## Neural Networks
111
+
112
+ ```python
113
+ import tensorstudio as ts
114
+ from tensorstudio import nn, optim
115
+
116
+ model = nn.Sequential(nn.Linear(1, 8), nn.Tanh(), nn.Linear(8, 1))
117
+ optimizer = optim.SGD(model.parameters(), lr=0.05)
118
+ criterion = nn.MSELoss()
119
+
120
+ x = ts.tensor([[0.0], [1.0], [2.0], [3.0]])
121
+ y = ts.tensor([[1.0], [3.0], [5.0], [7.0]])
122
+
123
+ for _ in range(50):
124
+ optimizer.zero_grad()
125
+ loss = criterion(model(x), y)
126
+ loss.backward()
127
+ optimizer.step()
128
+
129
+ print(loss.item())
130
+ ```
131
+
132
+ ## Development
133
+
134
+ ```bash
135
+ python -m pip install -e ".[dev]"
136
+ pytest
137
+ ruff check .
138
+ mypy python/tensorstudio
139
+ python -m build
140
+ ```
141
+
142
+ The native extension is built with CMake, pybind11, scikit-build-core, and C++20.
143
+
144
+ ## Documentation
145
+
146
+ The documentation lives in `docs/` and is configured with MkDocs:
147
+
148
+ ```bash
149
+ python -m pip install -e ".[docs]"
150
+ mkdocs serve
151
+ mkdocs build
152
+ ```
153
+
154
+ The docs cover tensor semantics, broadcasting, NumPy interop, autograd, neural
155
+ network modules, training loops, CPU backend details, benchmarks, development,
156
+ publishing, and the project roadmap.
157
+
158
+ ## Publishing
159
+
160
+ Releases are intended to be built by GitHub Actions. The publish workflow uses
161
+ PyPI trusted publishing through `pypa/gh-action-pypi-publish`; do not commit PyPI
162
+ API tokens.
163
+
164
+ ## Current Limitations
165
+
166
+ - CPU backend only
167
+ - Eager execution only
168
+ - No CUDA kernels or mixed precision
169
+ - No graph compiler or distributed training
170
+ - Limited dtype casting and no advanced indexing
171
+ - No sparse tensors
172
+ - Pickle serialization is for trusted TensorStudio objects only
173
+
174
+ ## Roadmap
175
+
176
+ - CUDA backend
177
+ - Graph/JIT mode
178
+ - Convolution ops
179
+ - Dataset utilities
180
+ - Model zoo examples
181
+ - ONNX import/export
182
+ - Improved memory allocator
183
+ - SIMD kernels
184
+ - Multithreaded ops
185
+
186
+ ## License
187
+
188
+ TensorStudio is licensed under the MIT License.
@@ -0,0 +1,130 @@
1
+ # TensorStudio
2
+
3
+ [![CI](https://github.com/tensorstudio/tensorstudio/actions/workflows/ci.yml/badge.svg)](https://github.com/tensorstudio/tensorstudio/actions/workflows/ci.yml)
4
+ [![Wheels](https://github.com/tensorstudio/tensorstudio/actions/workflows/wheels.yml/badge.svg)](https://github.com/tensorstudio/tensorstudio/actions/workflows/wheels.yml)
5
+ [![PyPI](https://img.shields.io/pypi/v/tensorstudio.svg)](https://pypi.org/project/tensorstudio/)
6
+
7
+ TensorStudio is a compact C++ tensor and autograd engine with a Python API for
8
+ learning, experimentation, and lightweight ML workloads.
9
+
10
+ TensorStudio is experimental v0.1.0 software. It is CPU-only, eager-only, and
11
+ intentionally small enough to read and modify.
12
+
13
+ ## Install
14
+
15
+ From a source checkout:
16
+
17
+ ```bash
18
+ python -m pip install -U pip
19
+ python -m pip install -e ".[dev]"
20
+ ```
21
+
22
+ Build source and wheel distributions:
23
+
24
+ ```bash
25
+ python -m build
26
+ ```
27
+
28
+ ## Quickstart
29
+
30
+ ```python
31
+ import tensorstudio as ts
32
+
33
+ x = ts.tensor([[1.0, 2.0], [3.0, 4.0]])
34
+ y = ts.ones((2, 2))
35
+
36
+ print((x + y).tolist())
37
+ print((x @ y).numpy())
38
+ ```
39
+
40
+ ## Autograd
41
+
42
+ ```python
43
+ import tensorstudio as ts
44
+
45
+ x = ts.tensor([1.0, 2.0, 3.0], requires_grad=True)
46
+ loss = ((x * x).sum())
47
+ loss.backward()
48
+
49
+ print(x.grad.tolist()) # [2.0, 4.0, 6.0]
50
+ ```
51
+
52
+ ## Neural Networks
53
+
54
+ ```python
55
+ import tensorstudio as ts
56
+ from tensorstudio import nn, optim
57
+
58
+ model = nn.Sequential(nn.Linear(1, 8), nn.Tanh(), nn.Linear(8, 1))
59
+ optimizer = optim.SGD(model.parameters(), lr=0.05)
60
+ criterion = nn.MSELoss()
61
+
62
+ x = ts.tensor([[0.0], [1.0], [2.0], [3.0]])
63
+ y = ts.tensor([[1.0], [3.0], [5.0], [7.0]])
64
+
65
+ for _ in range(50):
66
+ optimizer.zero_grad()
67
+ loss = criterion(model(x), y)
68
+ loss.backward()
69
+ optimizer.step()
70
+
71
+ print(loss.item())
72
+ ```
73
+
74
+ ## Development
75
+
76
+ ```bash
77
+ python -m pip install -e ".[dev]"
78
+ pytest
79
+ ruff check .
80
+ mypy python/tensorstudio
81
+ python -m build
82
+ ```
83
+
84
+ The native extension is built with CMake, pybind11, scikit-build-core, and C++20.
85
+
86
+ ## Documentation
87
+
88
+ The documentation lives in `docs/` and is configured with MkDocs:
89
+
90
+ ```bash
91
+ python -m pip install -e ".[docs]"
92
+ mkdocs serve
93
+ mkdocs build
94
+ ```
95
+
96
+ The docs cover tensor semantics, broadcasting, NumPy interop, autograd, neural
97
+ network modules, training loops, CPU backend details, benchmarks, development,
98
+ publishing, and the project roadmap.
99
+
100
+ ## Publishing
101
+
102
+ Releases are intended to be built by GitHub Actions. The publish workflow uses
103
+ PyPI trusted publishing through `pypa/gh-action-pypi-publish`; do not commit PyPI
104
+ API tokens.
105
+
106
+ ## Current Limitations
107
+
108
+ - CPU backend only
109
+ - Eager execution only
110
+ - No CUDA kernels or mixed precision
111
+ - No graph compiler or distributed training
112
+ - Limited dtype casting and no advanced indexing
113
+ - No sparse tensors
114
+ - Pickle serialization is for trusted TensorStudio objects only
115
+
116
+ ## Roadmap
117
+
118
+ - CUDA backend
119
+ - Graph/JIT mode
120
+ - Convolution ops
121
+ - Dataset utilities
122
+ - Model zoo examples
123
+ - ONNX import/export
124
+ - Improved memory allocator
125
+ - SIMD kernels
126
+ - Multithreaded ops
127
+
128
+ ## License
129
+
130
+ TensorStudio is licensed under the MIT License.
@@ -0,0 +1,21 @@
1
+ # Security Policy
2
+
3
+ TensorStudio is experimental v0.1.0 software.
4
+
5
+ ## Reporting a Vulnerability
6
+
7
+ Please report suspected vulnerabilities by opening a private security advisory
8
+ on GitHub or by contacting the maintainers through the project repository.
9
+
10
+ Include:
11
+
12
+ - Affected version or commit
13
+ - Reproduction steps
14
+ - Impact assessment
15
+ - Suggested fix, if available
16
+
17
+ ## Serialization Warning
18
+
19
+ `tensorstudio.load()` uses Python pickle for v0.1.0 internal object roundtrips.
20
+ Loading pickle files from untrusted sources is unsafe because pickle can execute
21
+ arbitrary code during deserialization.
@@ -0,0 +1,28 @@
1
+ from __future__ import annotations
2
+
3
+ import time
4
+
5
+ import tensorstudio as ts
6
+
7
+
8
+ def timeit(name: str, fn, iterations: int = 5) -> None:
9
+ start = time.perf_counter()
10
+ for _ in range(iterations):
11
+ fn()
12
+ elapsed = (time.perf_counter() - start) / iterations
13
+ print(f"{name}: {elapsed * 1_000:.3f} ms")
14
+
15
+
16
+ def main() -> None:
17
+ shape = (128, 128)
18
+ a_ts = ts.randn(shape, seed=1)
19
+ b_ts = ts.randn(shape, seed=2)
20
+ a_np = a_ts.numpy()
21
+ b_np = b_ts.numpy()
22
+
23
+ timeit("tensorstudio matmul", lambda: a_ts @ b_ts)
24
+ timeit("numpy matmul", lambda: a_np @ b_np)
25
+
26
+
27
+ if __name__ == "__main__":
28
+ main()
@@ -0,0 +1,31 @@
1
+ from __future__ import annotations
2
+
3
+ import time
4
+
5
+ import numpy as np
6
+ import tensorstudio as ts
7
+
8
+
9
+ def timeit(name: str, fn, iterations: int = 20) -> None:
10
+ start = time.perf_counter()
11
+ for _ in range(iterations):
12
+ fn()
13
+ elapsed = (time.perf_counter() - start) / iterations
14
+ print(f"{name}: {elapsed * 1_000:.3f} ms")
15
+
16
+
17
+ def main() -> None:
18
+ size = 50_000
19
+ a_ts = ts.randn((size,), seed=1)
20
+ b_ts = ts.randn((size,), seed=2)
21
+ a_np = a_ts.numpy()
22
+ b_np = b_ts.numpy()
23
+
24
+ timeit("tensorstudio add", lambda: a_ts + b_ts)
25
+ timeit("numpy add", lambda: a_np + b_np)
26
+ timeit("tensorstudio relu", lambda: a_ts.relu())
27
+ timeit("numpy relu", lambda: np.maximum(a_np, 0))
28
+
29
+
30
+ if __name__ == "__main__":
31
+ main()