tensorstudio 1.1.0__tar.gz → 1.2.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.
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/CHANGELOG.md +14 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/PKG-INFO +90 -16
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/README.md +83 -15
- tensorstudio-1.2.0/benchmarks/results.md +353 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Autograde/index.md +1 -1
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Benchmarks/index.md +1 -1
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Hardware/cpu-backend.md +1 -1
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Neural Networks/training.md +1 -1
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Roadmap/index.md +2 -2
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Usage/api.md +25 -1
- tensorstudio-1.2.0/docs/Usage/interchange.md +68 -0
- tensorstudio-1.2.0/docs/Usage/serialization.md +78 -0
- tensorstudio-1.2.0/docs/Vision/index.md +83 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/index.md +15 -10
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/publishing.md +4 -4
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/quickstart.md +43 -1
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/serialization.md +25 -4
- tensorstudio-1.2.0/examples/export_onnx.py +29 -0
- tensorstudio-1.2.0/examples/vision_classifier.py +30 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/version.hpp +1 -1
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/mkdocs.yml +2 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/pyproject.toml +9 -1
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/__init__.py +8 -2
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/_version.py +1 -1
- tensorstudio-1.2.0/python/tensorstudio/interchange/__init__.py +7 -0
- tensorstudio-1.2.0/python/tensorstudio/interchange/onnx.py +299 -0
- tensorstudio-1.2.0/python/tensorstudio/serialization.py +136 -0
- tensorstudio-1.2.0/python/tensorstudio/vision/__init__.py +15 -0
- tensorstudio-1.2.0/python/tensorstudio/vision/models.py +59 -0
- tensorstudio-1.2.0/python/tensorstudio/vision/transforms.py +184 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/test_all.py +2 -6
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_import.py +3 -1
- tensorstudio-1.2.0/tests/test_interchange.py +43 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_serialization.py +26 -0
- tensorstudio-1.2.0/tests/test_vision.py +52 -0
- tensorstudio-1.1.0/benchmarks/results.md +0 -353
- tensorstudio-1.1.0/docs/Usage/serialization.md +0 -43
- tensorstudio-1.1.0/python/tensorstudio/serialization.py +0 -34
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/.github/workflows/ci.yml +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/.github/workflows/publish-testpypi.yml +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/.github/workflows/publish.yml +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/.github/workflows/wheels.yml +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/.gitignore +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/.pre-commit-config.yaml +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/CMakeLists.txt +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/CONTRIBUTING.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/LICENSE +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/SECURITY.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmark_all.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/__init__.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/bench_activations.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/bench_autograd.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/bench_conv2d.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/bench_elementwise.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/bench_matmul.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/bench_pooling.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/bench_reductions.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/bench_tensor_ops.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/bench_training_loop.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/benchmark_report.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/results_conv2d.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/results_matmul.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/results_pooling.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/results_reductions.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/benchmarks/results_tensor_ops.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Autograde/autograd.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Hardware/linux.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Hardware/macos.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Hardware/windows.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Neural Networks/modules.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Neural Networks/nn.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Usage/data.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Usage/numpy-interop.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Usage/optim.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/Usage/tensors.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/docs/development.md +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/examples/basic_tensor_ops.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/examples/linear_regression.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/examples/save_load_model.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/examples/tiny_mlp.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/autograd.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/device.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/dtype.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/errors.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/module.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/ops.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/optim.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/random.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/serialization.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/shape.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/storage.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/include/tensorstudio/tensor.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/_C.pyi +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/autograd.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/data/__init__.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/data/dataloader.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/data/dataset.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/errors.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/grad_mode.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/nn/__init__.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/nn/functional.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/nn/losses.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/nn/modules.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/ops.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/optim/__init__.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/optim/adam.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/optim/adamw.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/optim/lr_scheduler.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/optim/sgd.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/optim/utils.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/py.typed +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/tensor.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/python/tensorstudio/typing.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/bindings/bind_autograd.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/bindings/bind_nn.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/bindings/bind_ops.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/bindings/bind_optim.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/bindings/bind_tensor.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/bindings/bindings.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/bindings/bindings.hpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/autograd.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/device.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/dtype.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/errors.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/module.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/ops.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/optim.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/random.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/serialization.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/shape.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/storage.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/src/core/tensor.cpp +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_autograd.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_benchmark_report.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_data.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_nn.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_numpy_interop.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_ops.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_optim.py +0 -0
- {tensorstudio-1.1.0 → tensorstudio-1.2.0}/tests/test_tensor.py +0 -0
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.2.0 - 2026-07-07
|
|
6
|
+
|
|
7
|
+
- Added `save_npz` and `load_npz` for non-pickle tensor and flat
|
|
8
|
+
`state_dict` files using NumPy NPZ archives plus TensorStudio JSON metadata.
|
|
9
|
+
- Added optional ONNX export through `tensorstudio.export_onnx` and
|
|
10
|
+
`tensorstudio.interchange.export_onnx` for supported Sequential module
|
|
11
|
+
stacks.
|
|
12
|
+
- Added `tensorstudio.vision` with image-to-tensor conversion, normalization,
|
|
13
|
+
center crop, nearest-neighbor resize, and a small `TinyConvClassifier`.
|
|
14
|
+
- Added tests for NPZ roundtrips, ONNX graph validation, and vision classifier
|
|
15
|
+
forward/backward behavior.
|
|
16
|
+
- Updated README and MkDocs pages for file formats, ONNX limits, and vision
|
|
17
|
+
workflows.
|
|
18
|
+
|
|
5
19
|
## 1.1.0 - 2026-07-07
|
|
6
20
|
|
|
7
21
|
- Added native CPU NCHW `conv2d` with stride, padding, dilation, optional bias,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: tensorstudio
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: TensorStudio is a compact C++ tensor and autograd engine with a Python API for learning, experimentation, and lightweight ML workloads.
|
|
5
5
|
Keywords: tensor,autograd,machine-learning,cpp,pybind11
|
|
6
6
|
Author: TensorStudio contributors
|
|
@@ -51,9 +51,15 @@ Requires-Dist: ruff>=0.6; extra == "dev"
|
|
|
51
51
|
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
52
52
|
Requires-Dist: cibuildwheel>=2.19; extra == "dev"
|
|
53
53
|
Requires-Dist: pre-commit>=3.7; extra == "dev"
|
|
54
|
+
Requires-Dist: onnx>=1.16; extra == "dev"
|
|
55
|
+
Requires-Dist: Pillow>=10; extra == "dev"
|
|
54
56
|
Provides-Extra: docs
|
|
55
57
|
Requires-Dist: mkdocs>=1.6; extra == "docs"
|
|
56
58
|
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
59
|
+
Provides-Extra: onnx
|
|
60
|
+
Requires-Dist: onnx>=1.16; extra == "onnx"
|
|
61
|
+
Provides-Extra: vision
|
|
62
|
+
Requires-Dist: Pillow>=10; extra == "vision"
|
|
57
63
|
Description-Content-Type: text/markdown
|
|
58
64
|
|
|
59
65
|
# TensorStudio
|
|
@@ -65,7 +71,7 @@ Description-Content-Type: text/markdown
|
|
|
65
71
|
TensorStudio is a compact C++ tensor and autograd engine with a Python API for
|
|
66
72
|
learning, experimentation, and lightweight ML workloads.
|
|
67
73
|
|
|
68
|
-
TensorStudio `1.
|
|
74
|
+
TensorStudio `1.2.0` is a CPU-only stable API foundation. It is eager-only,
|
|
69
75
|
intentionally small, and not a replacement for mature ML frameworks.
|
|
70
76
|
|
|
71
77
|
## Install
|
|
@@ -83,6 +89,12 @@ python -m pip install -U pip
|
|
|
83
89
|
python -m pip install -e ".[dev]"
|
|
84
90
|
```
|
|
85
91
|
|
|
92
|
+
Install optional extras for ONNX export and Pillow-backed image inputs:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
python -m pip install "tensorstudio[onnx,vision]"
|
|
96
|
+
```
|
|
97
|
+
|
|
86
98
|
Build source and wheel distributions:
|
|
87
99
|
|
|
88
100
|
```bash
|
|
@@ -206,6 +218,32 @@ print(model.state_dict().keys())
|
|
|
206
218
|
print(model.parameter_count())
|
|
207
219
|
```
|
|
208
220
|
|
|
221
|
+
## Vision
|
|
222
|
+
|
|
223
|
+
TensorStudio includes a small vision namespace for image preprocessing and
|
|
224
|
+
compact CNN classifiers. Image file decoding remains the job of Pillow or other
|
|
225
|
+
image libraries; TensorStudio converts image-like arrays into channel-first
|
|
226
|
+
tensors and runs the model with its native Conv2d and pooling kernels.
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
import numpy as np
|
|
230
|
+
import tensorstudio as ts
|
|
231
|
+
from tensorstudio import nn, optim
|
|
232
|
+
|
|
233
|
+
image = np.zeros((8, 8, 3), dtype=np.uint8)
|
|
234
|
+
x = ts.vision.to_tensor(image).reshape((1, 3, 8, 8))
|
|
235
|
+
x = ts.vision.normalize(x, mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5))
|
|
236
|
+
|
|
237
|
+
model = ts.vision.TinyConvClassifier((3, 8, 8), num_classes=2)
|
|
238
|
+
target = ts.tensor([1], dtype="int64")
|
|
239
|
+
optimizer = optim.SGD(model.parameters(), lr=0.01)
|
|
240
|
+
|
|
241
|
+
optimizer.zero_grad()
|
|
242
|
+
loss = nn.CrossEntropyLoss()(model(x), target)
|
|
243
|
+
loss.backward()
|
|
244
|
+
optimizer.step()
|
|
245
|
+
```
|
|
246
|
+
|
|
209
247
|
## DataLoader
|
|
210
248
|
|
|
211
249
|
```python
|
|
@@ -237,10 +275,10 @@ python benchmarks/benchmark_report.py
|
|
|
237
275
|
columns for NumPy, TensorFlow, PyTorch, and JAX when those libraries are
|
|
238
276
|
available locally.
|
|
239
277
|
|
|
240
|
-
On one Windows CPython 3.10 development run reporting `1.
|
|
241
|
-
beat NumPy on
|
|
242
|
-
NumPy-comparable cases. Against PyTorch CPU `2.12.1+cpu`, TensorStudio won
|
|
243
|
-
local cases and lost
|
|
278
|
+
On one Windows CPython 3.10 development run reporting `1.2.0`, TensorStudio
|
|
279
|
+
beat NumPy on 26 small operation benchmark cases and lost on 77
|
|
280
|
+
NumPy-comparable cases. Against PyTorch CPU `2.12.1+cpu`, TensorStudio won 75
|
|
281
|
+
local cases and lost 33. The strongest local wins were small eager operations,
|
|
244
282
|
small contiguous axis reductions, and the simple NumPy convolution/pooling
|
|
245
283
|
references where framework dispatch or Python loops dominate; larger matrix
|
|
246
284
|
multiplication, PyTorch convolution and pooling, larger axis reductions, larger
|
|
@@ -253,15 +291,15 @@ Snapshot from that local run:
|
|
|
253
291
|
|
|
254
292
|
| operation | shape | TensorStudio | NumPy | PyTorch CPU | TS vs NumPy | TS vs PyTorch |
|
|
255
293
|
|---|---:|---:|---:|---:|---:|---:|
|
|
256
|
-
| `sigmoid` | `(32,)` | 0.0017 ms | 0.
|
|
257
|
-
| `mean` | `(32,)` | 0.
|
|
258
|
-
| `sum_axis1` | `(16, 16)` | 0.
|
|
259
|
-
| `chain_relu` | `(128,)` | 0.
|
|
260
|
-
| `matmul` | `(256, 256)` | 4.
|
|
261
|
-
| `conv2d_3x3_padding1` | `(1, 1, 8, 8)` | 0.
|
|
262
|
-
| `max_pool2d_2x2` | `(1, 1, 16, 16)` | 0.
|
|
263
|
-
| `avg_pool2d_2x2` | `(1, 1, 16, 16)` | 0.
|
|
264
|
-
| `elementwise_backward` | `(1024,)` |
|
|
294
|
+
| `sigmoid` | `(32,)` | 0.0017 ms | 0.0038 ms | 0.0614 ms | 2.1691x | 35.3154x |
|
|
295
|
+
| `mean` | `(32,)` | 0.0029 ms | 0.0131 ms | 0.0186 ms | 4.5638x | 6.4709x |
|
|
296
|
+
| `sum_axis1` | `(16, 16)` | 0.0027 ms | 0.0029 ms | 0.0085 ms | 1.0894x | 3.1408x |
|
|
297
|
+
| `chain_relu` | `(128,)` | 0.0112 ms | 0.0051 ms | 0.0726 ms | 0.4575x | 6.4533x |
|
|
298
|
+
| `matmul` | `(256, 256)` | 4.4121 ms | 0.3779 ms | 0.1669 ms | 0.0856x | 0.0378x |
|
|
299
|
+
| `conv2d_3x3_padding1` | `(1, 1, 8, 8)` | 0.2374 ms | 1.7112 ms | 0.0186 ms | 7.2091x | 0.0784x |
|
|
300
|
+
| `max_pool2d_2x2` | `(1, 1, 16, 16)` | 0.0237 ms | 0.2764 ms | 0.0082 ms | 11.6685x | 0.3462x |
|
|
301
|
+
| `avg_pool2d_2x2` | `(1, 1, 16, 16)` | 0.0198 ms | 0.7431 ms | 0.0073 ms | 37.4930x | 0.3662x |
|
|
302
|
+
| `elementwise_backward` | `(1024,)` | 3.0196 ms | n/a | 0.2254 ms | n/a | 0.0746x |
|
|
265
303
|
|
|
266
304
|
Speedup is `competitor median / TensorStudio median`, so values above `1.0x`
|
|
267
305
|
favor TensorStudio.
|
|
@@ -283,6 +321,39 @@ checkpoint = ts.load("checkpoint.tsmodel")
|
|
|
283
321
|
Serialization uses pickle. Loading pickle files from untrusted sources is
|
|
284
322
|
unsafe because pickle can execute arbitrary code.
|
|
285
323
|
|
|
324
|
+
For safer tensor and `state_dict` interchange, use TensorStudio's non-pickle
|
|
325
|
+
NPZ helpers:
|
|
326
|
+
|
|
327
|
+
```python
|
|
328
|
+
state = model.state_dict()
|
|
329
|
+
ts.save_npz(state, "weights.tsnpz")
|
|
330
|
+
model.load_state_dict(ts.load_npz("weights.tsnpz"))
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## ONNX Export
|
|
334
|
+
|
|
335
|
+
TensorStudio can export a supported `nn.Sequential` graph to ONNX when the
|
|
336
|
+
optional `onnx` extra is installed:
|
|
337
|
+
|
|
338
|
+
```python
|
|
339
|
+
import tensorstudio as ts
|
|
340
|
+
from tensorstudio import nn
|
|
341
|
+
|
|
342
|
+
model = nn.Sequential(
|
|
343
|
+
nn.Conv2d(1, 2, kernel_size=3, padding=1),
|
|
344
|
+
nn.ReLU(),
|
|
345
|
+
nn.MaxPool2d(2),
|
|
346
|
+
nn.Flatten(),
|
|
347
|
+
nn.Linear(2 * 2 * 2, 3),
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
ts.export_onnx(model, "classifier.onnx", input_shape=(1, 1, 4, 4))
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
The v1.2 exporter supports `Linear`, `Conv2d`, `Flatten`, `ReLU`, `Sigmoid`,
|
|
354
|
+
`Tanh`, `MaxPool2d`, and `AvgPool2d`. It is an exporter, not an ONNX runtime or
|
|
355
|
+
importer.
|
|
356
|
+
|
|
286
357
|
## Development
|
|
287
358
|
|
|
288
359
|
```bash
|
|
@@ -329,6 +400,9 @@ tokens or print secrets.
|
|
|
329
400
|
- No graph compiler or distributed runtime.
|
|
330
401
|
- Convolution and pooling support are currently limited to CPU NCHW
|
|
331
402
|
`conv2d`, `max_pool2d`, and `avg_pool2d` style workloads.
|
|
403
|
+
- Vision utilities are preprocessing and small CNN helpers, not a full computer
|
|
404
|
+
vision library.
|
|
405
|
+
- ONNX support is export-only for a limited set of TensorStudio modules.
|
|
332
406
|
- Reductions support all-element or single-axis reductions, not tuple-axis
|
|
333
407
|
reductions yet.
|
|
334
408
|
- No sparse tensors or advanced indexing.
|
|
@@ -343,7 +417,7 @@ tokens or print secrets.
|
|
|
343
417
|
- Broader convolution ops, adaptive/global pooling, and image-model examples
|
|
344
418
|
- Richer dataset utilities
|
|
345
419
|
- Model zoo examples
|
|
346
|
-
- ONNX import
|
|
420
|
+
- ONNX import and broader export coverage
|
|
347
421
|
- Improved memory allocator
|
|
348
422
|
- SIMD kernels
|
|
349
423
|
- Multithreaded ops
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
TensorStudio is a compact C++ tensor and autograd engine with a Python API for
|
|
8
8
|
learning, experimentation, and lightweight ML workloads.
|
|
9
9
|
|
|
10
|
-
TensorStudio `1.
|
|
10
|
+
TensorStudio `1.2.0` is a CPU-only stable API foundation. It is eager-only,
|
|
11
11
|
intentionally small, and not a replacement for mature ML frameworks.
|
|
12
12
|
|
|
13
13
|
## Install
|
|
@@ -25,6 +25,12 @@ python -m pip install -U pip
|
|
|
25
25
|
python -m pip install -e ".[dev]"
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
Install optional extras for ONNX export and Pillow-backed image inputs:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
python -m pip install "tensorstudio[onnx,vision]"
|
|
32
|
+
```
|
|
33
|
+
|
|
28
34
|
Build source and wheel distributions:
|
|
29
35
|
|
|
30
36
|
```bash
|
|
@@ -148,6 +154,32 @@ print(model.state_dict().keys())
|
|
|
148
154
|
print(model.parameter_count())
|
|
149
155
|
```
|
|
150
156
|
|
|
157
|
+
## Vision
|
|
158
|
+
|
|
159
|
+
TensorStudio includes a small vision namespace for image preprocessing and
|
|
160
|
+
compact CNN classifiers. Image file decoding remains the job of Pillow or other
|
|
161
|
+
image libraries; TensorStudio converts image-like arrays into channel-first
|
|
162
|
+
tensors and runs the model with its native Conv2d and pooling kernels.
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
import numpy as np
|
|
166
|
+
import tensorstudio as ts
|
|
167
|
+
from tensorstudio import nn, optim
|
|
168
|
+
|
|
169
|
+
image = np.zeros((8, 8, 3), dtype=np.uint8)
|
|
170
|
+
x = ts.vision.to_tensor(image).reshape((1, 3, 8, 8))
|
|
171
|
+
x = ts.vision.normalize(x, mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5))
|
|
172
|
+
|
|
173
|
+
model = ts.vision.TinyConvClassifier((3, 8, 8), num_classes=2)
|
|
174
|
+
target = ts.tensor([1], dtype="int64")
|
|
175
|
+
optimizer = optim.SGD(model.parameters(), lr=0.01)
|
|
176
|
+
|
|
177
|
+
optimizer.zero_grad()
|
|
178
|
+
loss = nn.CrossEntropyLoss()(model(x), target)
|
|
179
|
+
loss.backward()
|
|
180
|
+
optimizer.step()
|
|
181
|
+
```
|
|
182
|
+
|
|
151
183
|
## DataLoader
|
|
152
184
|
|
|
153
185
|
```python
|
|
@@ -179,10 +211,10 @@ python benchmarks/benchmark_report.py
|
|
|
179
211
|
columns for NumPy, TensorFlow, PyTorch, and JAX when those libraries are
|
|
180
212
|
available locally.
|
|
181
213
|
|
|
182
|
-
On one Windows CPython 3.10 development run reporting `1.
|
|
183
|
-
beat NumPy on
|
|
184
|
-
NumPy-comparable cases. Against PyTorch CPU `2.12.1+cpu`, TensorStudio won
|
|
185
|
-
local cases and lost
|
|
214
|
+
On one Windows CPython 3.10 development run reporting `1.2.0`, TensorStudio
|
|
215
|
+
beat NumPy on 26 small operation benchmark cases and lost on 77
|
|
216
|
+
NumPy-comparable cases. Against PyTorch CPU `2.12.1+cpu`, TensorStudio won 75
|
|
217
|
+
local cases and lost 33. The strongest local wins were small eager operations,
|
|
186
218
|
small contiguous axis reductions, and the simple NumPy convolution/pooling
|
|
187
219
|
references where framework dispatch or Python loops dominate; larger matrix
|
|
188
220
|
multiplication, PyTorch convolution and pooling, larger axis reductions, larger
|
|
@@ -195,15 +227,15 @@ Snapshot from that local run:
|
|
|
195
227
|
|
|
196
228
|
| operation | shape | TensorStudio | NumPy | PyTorch CPU | TS vs NumPy | TS vs PyTorch |
|
|
197
229
|
|---|---:|---:|---:|---:|---:|---:|
|
|
198
|
-
| `sigmoid` | `(32,)` | 0.0017 ms | 0.
|
|
199
|
-
| `mean` | `(32,)` | 0.
|
|
200
|
-
| `sum_axis1` | `(16, 16)` | 0.
|
|
201
|
-
| `chain_relu` | `(128,)` | 0.
|
|
202
|
-
| `matmul` | `(256, 256)` | 4.
|
|
203
|
-
| `conv2d_3x3_padding1` | `(1, 1, 8, 8)` | 0.
|
|
204
|
-
| `max_pool2d_2x2` | `(1, 1, 16, 16)` | 0.
|
|
205
|
-
| `avg_pool2d_2x2` | `(1, 1, 16, 16)` | 0.
|
|
206
|
-
| `elementwise_backward` | `(1024,)` |
|
|
230
|
+
| `sigmoid` | `(32,)` | 0.0017 ms | 0.0038 ms | 0.0614 ms | 2.1691x | 35.3154x |
|
|
231
|
+
| `mean` | `(32,)` | 0.0029 ms | 0.0131 ms | 0.0186 ms | 4.5638x | 6.4709x |
|
|
232
|
+
| `sum_axis1` | `(16, 16)` | 0.0027 ms | 0.0029 ms | 0.0085 ms | 1.0894x | 3.1408x |
|
|
233
|
+
| `chain_relu` | `(128,)` | 0.0112 ms | 0.0051 ms | 0.0726 ms | 0.4575x | 6.4533x |
|
|
234
|
+
| `matmul` | `(256, 256)` | 4.4121 ms | 0.3779 ms | 0.1669 ms | 0.0856x | 0.0378x |
|
|
235
|
+
| `conv2d_3x3_padding1` | `(1, 1, 8, 8)` | 0.2374 ms | 1.7112 ms | 0.0186 ms | 7.2091x | 0.0784x |
|
|
236
|
+
| `max_pool2d_2x2` | `(1, 1, 16, 16)` | 0.0237 ms | 0.2764 ms | 0.0082 ms | 11.6685x | 0.3462x |
|
|
237
|
+
| `avg_pool2d_2x2` | `(1, 1, 16, 16)` | 0.0198 ms | 0.7431 ms | 0.0073 ms | 37.4930x | 0.3662x |
|
|
238
|
+
| `elementwise_backward` | `(1024,)` | 3.0196 ms | n/a | 0.2254 ms | n/a | 0.0746x |
|
|
207
239
|
|
|
208
240
|
Speedup is `competitor median / TensorStudio median`, so values above `1.0x`
|
|
209
241
|
favor TensorStudio.
|
|
@@ -225,6 +257,39 @@ checkpoint = ts.load("checkpoint.tsmodel")
|
|
|
225
257
|
Serialization uses pickle. Loading pickle files from untrusted sources is
|
|
226
258
|
unsafe because pickle can execute arbitrary code.
|
|
227
259
|
|
|
260
|
+
For safer tensor and `state_dict` interchange, use TensorStudio's non-pickle
|
|
261
|
+
NPZ helpers:
|
|
262
|
+
|
|
263
|
+
```python
|
|
264
|
+
state = model.state_dict()
|
|
265
|
+
ts.save_npz(state, "weights.tsnpz")
|
|
266
|
+
model.load_state_dict(ts.load_npz("weights.tsnpz"))
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## ONNX Export
|
|
270
|
+
|
|
271
|
+
TensorStudio can export a supported `nn.Sequential` graph to ONNX when the
|
|
272
|
+
optional `onnx` extra is installed:
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
import tensorstudio as ts
|
|
276
|
+
from tensorstudio import nn
|
|
277
|
+
|
|
278
|
+
model = nn.Sequential(
|
|
279
|
+
nn.Conv2d(1, 2, kernel_size=3, padding=1),
|
|
280
|
+
nn.ReLU(),
|
|
281
|
+
nn.MaxPool2d(2),
|
|
282
|
+
nn.Flatten(),
|
|
283
|
+
nn.Linear(2 * 2 * 2, 3),
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
ts.export_onnx(model, "classifier.onnx", input_shape=(1, 1, 4, 4))
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The v1.2 exporter supports `Linear`, `Conv2d`, `Flatten`, `ReLU`, `Sigmoid`,
|
|
290
|
+
`Tanh`, `MaxPool2d`, and `AvgPool2d`. It is an exporter, not an ONNX runtime or
|
|
291
|
+
importer.
|
|
292
|
+
|
|
228
293
|
## Development
|
|
229
294
|
|
|
230
295
|
```bash
|
|
@@ -271,6 +336,9 @@ tokens or print secrets.
|
|
|
271
336
|
- No graph compiler or distributed runtime.
|
|
272
337
|
- Convolution and pooling support are currently limited to CPU NCHW
|
|
273
338
|
`conv2d`, `max_pool2d`, and `avg_pool2d` style workloads.
|
|
339
|
+
- Vision utilities are preprocessing and small CNN helpers, not a full computer
|
|
340
|
+
vision library.
|
|
341
|
+
- ONNX support is export-only for a limited set of TensorStudio modules.
|
|
274
342
|
- Reductions support all-element or single-axis reductions, not tuple-axis
|
|
275
343
|
reductions yet.
|
|
276
344
|
- No sparse tensors or advanced indexing.
|
|
@@ -285,7 +353,7 @@ tokens or print secrets.
|
|
|
285
353
|
- Broader convolution ops, adaptive/global pooling, and image-model examples
|
|
286
354
|
- Richer dataset utilities
|
|
287
355
|
- Model zoo examples
|
|
288
|
-
- ONNX import
|
|
356
|
+
- ONNX import and broader export coverage
|
|
289
357
|
- Improved memory allocator
|
|
290
358
|
- SIMD kernels
|
|
291
359
|
- Multithreaded ops
|