DepthTensor 2.7.0__tar.gz → 3.0.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 (68) hide show
  1. {depthtensor-2.7.0 → depthtensor-3.0.0}/LICENSE +1 -1
  2. depthtensor-3.0.0/MANIFEST.in +1 -0
  3. depthtensor-3.0.0/PKG-INFO +119 -0
  4. depthtensor-3.0.0/README.md +100 -0
  5. depthtensor-3.0.0/csrc/bindings/bind_nn.cpp +29 -0
  6. depthtensor-3.0.0/csrc/bindings/main.cpp +11 -0
  7. depthtensor-3.0.0/csrc/cpu/nn/activations.cpp +19 -0
  8. depthtensor-3.0.0/csrc/include/nn/activations.h +9 -0
  9. depthtensor-3.0.0/depthtensor.egg-info/PKG-INFO +119 -0
  10. depthtensor-3.0.0/depthtensor.egg-info/SOURCES.txt +42 -0
  11. {depthtensor-2.7.0/src → depthtensor-3.0.0}/depthtensor.egg-info/requires.txt +1 -1
  12. depthtensor-3.0.0/depthtensor.egg-info/top_level.txt +1 -0
  13. {depthtensor-2.7.0 → depthtensor-3.0.0}/pyproject.toml +10 -10
  14. depthtensor-3.0.0/setup.py +37 -0
  15. depthtensor-3.0.0/src/DepthTensor/__init__.py +155 -0
  16. depthtensor-3.0.0/src/DepthTensor/_core/__init__.py +0 -0
  17. depthtensor-3.0.0/src/DepthTensor/_core/autograd.py +123 -0
  18. depthtensor-3.0.0/src/DepthTensor/_core/exceptions.py +15 -0
  19. depthtensor-3.0.0/src/DepthTensor/_core/indexing.py +180 -0
  20. depthtensor-3.0.0/src/DepthTensor/_core/nn/__init__.py +0 -0
  21. depthtensor-3.0.0/src/DepthTensor/_core/nn/_backend/__init__.py +1 -0
  22. depthtensor-3.0.0/src/DepthTensor/_core/nn/_backend/activation_functions.py +204 -0
  23. depthtensor-3.0.0/src/DepthTensor/_core/nn/functional/__init__.py +1 -0
  24. depthtensor-3.0.0/src/DepthTensor/_core/nn/functional/activation_functions.py +20 -0
  25. depthtensor-3.0.0/src/DepthTensor/_core/ops/__init__.py +0 -0
  26. depthtensor-3.0.0/src/DepthTensor/_core/ops/comparison.py +616 -0
  27. depthtensor-3.0.0/src/DepthTensor/_core/ops/creation.py +252 -0
  28. depthtensor-3.0.0/src/DepthTensor/_core/ops/elementwise.py +1758 -0
  29. depthtensor-3.0.0/src/DepthTensor/_core/ops/function.py +32 -0
  30. depthtensor-3.0.0/src/DepthTensor/_core/ops/reduction.py +587 -0
  31. depthtensor-3.0.0/src/DepthTensor/_core/output.py +180 -0
  32. depthtensor-3.0.0/src/DepthTensor/_core/random/__init__.py +0 -0
  33. depthtensor-3.0.0/src/DepthTensor/_core/random/generator.py +322 -0
  34. depthtensor-3.0.0/src/DepthTensor/_core/storage.py +132 -0
  35. depthtensor-3.0.0/src/DepthTensor/_core/utils.py +402 -0
  36. depthtensor-3.0.0/src/DepthTensor/_ext/__init__.pyi +7 -0
  37. depthtensor-3.0.0/src/DepthTensor/_ext/nn.pyi +41 -0
  38. depthtensor-3.0.0/src/DepthTensor/enum/__init__.py +5 -0
  39. depthtensor-3.0.0/src/DepthTensor/enum/initialize_grad.py +6 -0
  40. depthtensor-3.0.0/src/DepthTensor/tensor.py +1928 -0
  41. {depthtensor-2.7.0 → depthtensor-3.0.0}/src/DepthTensor/typing.py +2 -10
  42. depthtensor-3.0.0/tests/test_env.py +2 -0
  43. depthtensor-2.7.0/PKG-INFO +0 -149
  44. depthtensor-2.7.0/README.md +0 -108
  45. depthtensor-2.7.0/src/DepthTensor/__init__.py +0 -9
  46. depthtensor-2.7.0/src/DepthTensor/_core/__init__.py +0 -4
  47. depthtensor-2.7.0/src/DepthTensor/_core/exceptions.py +0 -16
  48. depthtensor-2.7.0/src/DepthTensor/_core/ops/__init__.py +0 -5
  49. depthtensor-2.7.0/src/DepthTensor/_core/ops/comparison.py +0 -506
  50. depthtensor-2.7.0/src/DepthTensor/_core/ops/creation.py +0 -218
  51. depthtensor-2.7.0/src/DepthTensor/_core/ops/elementwise.py +0 -1455
  52. depthtensor-2.7.0/src/DepthTensor/_core/ops/function.py +0 -15
  53. depthtensor-2.7.0/src/DepthTensor/_core/ops/reduction.py +0 -240
  54. depthtensor-2.7.0/src/DepthTensor/_core/random/__init__.py +0 -1
  55. depthtensor-2.7.0/src/DepthTensor/_core/random/generator.py +0 -236
  56. depthtensor-2.7.0/src/DepthTensor/_core/utils.py +0 -284
  57. depthtensor-2.7.0/src/DepthTensor/autodiff.py +0 -109
  58. depthtensor-2.7.0/src/DepthTensor/tensor.py +0 -929
  59. depthtensor-2.7.0/src/depthtensor.egg-info/PKG-INFO +0 -149
  60. depthtensor-2.7.0/src/depthtensor.egg-info/SOURCES.txt +0 -28
  61. depthtensor-2.7.0/src/depthtensor.egg-info/top_level.txt +0 -1
  62. depthtensor-2.7.0/tests/test_autodiff.py +0 -148
  63. depthtensor-2.7.0/tests/test_autodiff_extended.py +0 -126
  64. depthtensor-2.7.0/tests/test_ops_forward.py +0 -82
  65. depthtensor-2.7.0/tests/test_tensor_errors.py +0 -47
  66. depthtensor-2.7.0/tests/test_tensor_init.py +0 -59
  67. {depthtensor-2.7.0/src → depthtensor-3.0.0}/depthtensor.egg-info/dependency_links.txt +0 -0
  68. {depthtensor-2.7.0 → depthtensor-3.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Ha Hong Le
3
+ Copyright (c) 2025 Hong Ha Le
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1 @@
1
+ recursive-include csrc *.cpp *.h
@@ -0,0 +1,119 @@
1
+ Metadata-Version: 2.4
2
+ Name: depthtensor
3
+ Version: 3.0.0
4
+ Summary: Tensor math and autograd on CPU and CUDA
5
+ Author-email: Hong Ha Le <lehahong1310@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/l-h-ha/DepthTensor
8
+ Project-URL: Bug Tracker, https://github.com/l-h-ha/DepthTensor/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: numpy
16
+ Provides-Extra: cuda
17
+ Requires-Dist: cupy; extra == "cuda"
18
+ Dynamic: license-file
19
+
20
+ # DepthTensor
21
+
22
+ DepthTensor provides broadcasted tensor math, reductions, matrix multiplication, and reverse-mode autodiff. It uses NumPy on CPU and CuPy on CUDA. For neural networks, see [DepthML](https://github.com/l-h-ha/DepthML).
23
+
24
+ DepthTensor supports real-valued tensors. Autograd requires a floating-point dtype.
25
+
26
+ ## Install
27
+
28
+ Use Python 3.10 or later. Pip installs NumPy and builds the C++ extension from source. Install a C++ compiler and Python development headers on Linux, or MSVC and the Windows SDK on Windows.
29
+
30
+ ### CPU
31
+
32
+ ```bash
33
+ python -m pip install depthtensor
34
+ ```
35
+
36
+ ### CPU + CUDA
37
+
38
+ On Linux or Windows, use a supported NVIDIA GPU and a compatible driver. Run `nvidia-smi` to check the CUDA version your driver supports. Choose one install command. [NVIDIA driver check](https://docs.nvidia.com/deploy/nvidia-smi/index.html#cuda-umd-version)
39
+
40
+ | CUDA | Install |
41
+ | --- | --- |
42
+ | 12.x | `python -m pip install depthtensor "cupy-cuda12x[ctk]"` |
43
+ | 13.x | `python -m pip install depthtensor "cupy-cuda13x[ctk]"` |
44
+
45
+ `[ctk]` installs CUDA libraries through pip. Remove `[ctk]` to use an installed CUDA Toolkit. Set `device = "cuda"` in the example. [CuPy installation guide](https://docs.cupy.dev/en/stable/install.html#installing-cupy-from-pypi)
46
+
47
+ `python -m pip install "depthtensor[cuda]"` uses CuPy's source package and requires an installed CUDA Toolkit. Use one CuPy package per environment. [CuPy source builds](https://docs.cupy.dev/en/stable/install.html#installing-cupy-from-source)
48
+
49
+ ## Build from source
50
+
51
+ Install from the repository root.
52
+
53
+ ```bash
54
+ python -m pip install .
55
+ ```
56
+
57
+ Build a wheel in `dist/` with pip.
58
+
59
+ ```bash
60
+ python -m pip wheel . --no-deps --wheel-dir dist
61
+ ```
62
+
63
+ ## Example
64
+
65
+ Minimize the Rosenbrock function with gradient descent.
66
+
67
+ ```python
68
+ import depthtensor as dt
69
+
70
+ device = "cpu"
71
+ x = dt.Tensor([1.2], device=device, requires_grad=True)
72
+ y = dt.Tensor([1.2], device=device, requires_grad=True)
73
+ a = dt.Tensor([1], device=device)
74
+ b = dt.Tensor([100], device=device)
75
+
76
+ lr = 0.001
77
+ for i in range(500):
78
+ loss = (a - x) ** 2 + b * (y - x**2) ** 2
79
+ loss.backward()
80
+ x.data -= lr * x.grad
81
+ y.data -= lr * y.grad
82
+ x.zero_grad()
83
+ y.zero_grad()
84
+
85
+ if i % 10 == 0:
86
+ print(loss.item())
87
+
88
+ print(f"({x.data}, {y.data})")
89
+ ```
90
+
91
+ ## CPU benchmarks
92
+
93
+ Intel i5-11400H, Windows 26200, Python 3.11.15.
94
+ DepthTensor 3.0.0, PyTorch 2.12.1+cpu, TensorFlow 2.21.0, NumPy 2.3.5.
95
+
96
+ Rounded median (min–max) in µs/call.
97
+
98
+ | Tasks | Input shapes | DepthTensor | PyTorch | TensorFlow |
99
+ | --- | --- | ---: | ---: | ---: |
100
+ | Vector add | `1024 each` | 26 (21–41) | **4** (4–12) | 36 (24–66) |
101
+ | Broadcast add | `1024×1024 + 1024` | 1747 (1354–2957) | **481** (312–1024) | 793 (535–932) |
102
+ | ReLU | `1024×1024` | 7961 (6033–9598) | **412** (337–620) | 516 (413–1148) |
103
+ | Row sum | `1024×1024` | 588 (427–800) | 274 (189–467) | **214** (187–384) |
104
+ | Matmul | `512×512 each` | 4192 (3350–5444) | 3210 (3079–3755) | **3077** (2760–4022) |
105
+ | Matmul → ReLU → MSE + backward | `256×128 @ 128×128` | 2255 (1858–3681) | **782** (580–911) | 1832 (1531–2672) |
106
+
107
+ DepthTensor ranked third in all six matmul runs.
108
+
109
+ Run from the repo root in a Python 3.11 venv.
110
+
111
+ ```bash
112
+ python -m pip install --index-url https://download.pytorch.org/whl/cpu "torch==2.12.1+cpu"
113
+ python -m pip install . "tensorflow-cpu==2.21.0" "numpy==2.3.5"
114
+ python benchmarks/run.py --runs 6
115
+ ```
116
+
117
+ ## License
118
+
119
+ [MIT](LICENSE).
@@ -0,0 +1,100 @@
1
+ # DepthTensor
2
+
3
+ DepthTensor provides broadcasted tensor math, reductions, matrix multiplication, and reverse-mode autodiff. It uses NumPy on CPU and CuPy on CUDA. For neural networks, see [DepthML](https://github.com/l-h-ha/DepthML).
4
+
5
+ DepthTensor supports real-valued tensors. Autograd requires a floating-point dtype.
6
+
7
+ ## Install
8
+
9
+ Use Python 3.10 or later. Pip installs NumPy and builds the C++ extension from source. Install a C++ compiler and Python development headers on Linux, or MSVC and the Windows SDK on Windows.
10
+
11
+ ### CPU
12
+
13
+ ```bash
14
+ python -m pip install depthtensor
15
+ ```
16
+
17
+ ### CPU + CUDA
18
+
19
+ On Linux or Windows, use a supported NVIDIA GPU and a compatible driver. Run `nvidia-smi` to check the CUDA version your driver supports. Choose one install command. [NVIDIA driver check](https://docs.nvidia.com/deploy/nvidia-smi/index.html#cuda-umd-version)
20
+
21
+ | CUDA | Install |
22
+ | --- | --- |
23
+ | 12.x | `python -m pip install depthtensor "cupy-cuda12x[ctk]"` |
24
+ | 13.x | `python -m pip install depthtensor "cupy-cuda13x[ctk]"` |
25
+
26
+ `[ctk]` installs CUDA libraries through pip. Remove `[ctk]` to use an installed CUDA Toolkit. Set `device = "cuda"` in the example. [CuPy installation guide](https://docs.cupy.dev/en/stable/install.html#installing-cupy-from-pypi)
27
+
28
+ `python -m pip install "depthtensor[cuda]"` uses CuPy's source package and requires an installed CUDA Toolkit. Use one CuPy package per environment. [CuPy source builds](https://docs.cupy.dev/en/stable/install.html#installing-cupy-from-source)
29
+
30
+ ## Build from source
31
+
32
+ Install from the repository root.
33
+
34
+ ```bash
35
+ python -m pip install .
36
+ ```
37
+
38
+ Build a wheel in `dist/` with pip.
39
+
40
+ ```bash
41
+ python -m pip wheel . --no-deps --wheel-dir dist
42
+ ```
43
+
44
+ ## Example
45
+
46
+ Minimize the Rosenbrock function with gradient descent.
47
+
48
+ ```python
49
+ import depthtensor as dt
50
+
51
+ device = "cpu"
52
+ x = dt.Tensor([1.2], device=device, requires_grad=True)
53
+ y = dt.Tensor([1.2], device=device, requires_grad=True)
54
+ a = dt.Tensor([1], device=device)
55
+ b = dt.Tensor([100], device=device)
56
+
57
+ lr = 0.001
58
+ for i in range(500):
59
+ loss = (a - x) ** 2 + b * (y - x**2) ** 2
60
+ loss.backward()
61
+ x.data -= lr * x.grad
62
+ y.data -= lr * y.grad
63
+ x.zero_grad()
64
+ y.zero_grad()
65
+
66
+ if i % 10 == 0:
67
+ print(loss.item())
68
+
69
+ print(f"({x.data}, {y.data})")
70
+ ```
71
+
72
+ ## CPU benchmarks
73
+
74
+ Intel i5-11400H, Windows 26200, Python 3.11.15.
75
+ DepthTensor 3.0.0, PyTorch 2.12.1+cpu, TensorFlow 2.21.0, NumPy 2.3.5.
76
+
77
+ Rounded median (min–max) in µs/call.
78
+
79
+ | Tasks | Input shapes | DepthTensor | PyTorch | TensorFlow |
80
+ | --- | --- | ---: | ---: | ---: |
81
+ | Vector add | `1024 each` | 26 (21–41) | **4** (4–12) | 36 (24–66) |
82
+ | Broadcast add | `1024×1024 + 1024` | 1747 (1354–2957) | **481** (312–1024) | 793 (535–932) |
83
+ | ReLU | `1024×1024` | 7961 (6033–9598) | **412** (337–620) | 516 (413–1148) |
84
+ | Row sum | `1024×1024` | 588 (427–800) | 274 (189–467) | **214** (187–384) |
85
+ | Matmul | `512×512 each` | 4192 (3350–5444) | 3210 (3079–3755) | **3077** (2760–4022) |
86
+ | Matmul → ReLU → MSE + backward | `256×128 @ 128×128` | 2255 (1858–3681) | **782** (580–911) | 1832 (1531–2672) |
87
+
88
+ DepthTensor ranked third in all six matmul runs.
89
+
90
+ Run from the repo root in a Python 3.11 venv.
91
+
92
+ ```bash
93
+ python -m pip install --index-url https://download.pytorch.org/whl/cpu "torch==2.12.1+cpu"
94
+ python -m pip install . "tensorflow-cpu==2.21.0" "numpy==2.3.5"
95
+ python benchmarks/run.py --runs 6
96
+ ```
97
+
98
+ ## License
99
+
100
+ [MIT](LICENSE).
@@ -0,0 +1,29 @@
1
+ #include <pybind11/pybind11.h>
2
+ #include <pybind11/numpy.h>
3
+
4
+ #include "nn/activations.h"
5
+
6
+ namespace py = pybind11;
7
+ using namespace depthtensor::nn;
8
+
9
+ template <typename T>
10
+ void py_relu_forward_cpu(py::array_t<T> tensor) {
11
+ constexpr int contiguous_flags = py::array::c_style | py::array::f_style;
12
+ if (!tensor.writeable() || !(tensor.flags() & contiguous_flags)) {
13
+ throw std::runtime_error("Tensor must be writable and contiguous.");
14
+ }
15
+
16
+ py::buffer_info buf = tensor.request();
17
+ T *ptr = static_cast<T *>(buf.ptr);
18
+
19
+ relu_forward_cpu_impl(ptr, buf.size);
20
+ }
21
+
22
+ void init_nn(py::module_ &m) {
23
+ py::module_ nn_m = m.def_submodule("nn", "Neural network ops.");
24
+
25
+ nn_m.def("relu_forward_cpu", &py_relu_forward_cpu<float>, py::arg("tensor").noconvert(),
26
+ "ReLU for float32");
27
+ nn_m.def("relu_forward_cpu", &py_relu_forward_cpu<double>, py::arg("tensor").noconvert(),
28
+ "ReLU for float64");
29
+ }
@@ -0,0 +1,11 @@
1
+ #include <pybind11/pybind11.h>
2
+
3
+ namespace py = pybind11;
4
+
5
+ void init_nn(py::module_ &m);
6
+
7
+ PYBIND11_MODULE(_ext, m) {
8
+ m.doc() = "DepthTensor C++ backend.";
9
+
10
+ init_nn(m);
11
+ }
@@ -0,0 +1,19 @@
1
+ #include "nn/activations.h"
2
+
3
+ namespace depthtensor {
4
+ namespace nn {
5
+ template <typename T>
6
+ void relu_forward_cpu_impl(T *data, size_t size) {
7
+ T zero = static_cast<T>(0);
8
+ for (size_t i = 0; i < size; i++) {
9
+ if (data[i] < zero) {
10
+ data[i] = zero;
11
+ }
12
+ }
13
+ }
14
+
15
+ template void relu_forward_cpu_impl<float>(float *data, size_t size);
16
+ template void relu_forward_cpu_impl<double>(double *data, size_t size);
17
+ template void relu_forward_cpu_impl<int>(int *data, size_t size);
18
+ }
19
+ }
@@ -0,0 +1,9 @@
1
+ #pragma once
2
+ #include <cstddef>
3
+
4
+ namespace depthtensor {
5
+ namespace nn {
6
+ template <typename T>
7
+ void relu_forward_cpu_impl(T *data, size_t size);
8
+ }
9
+ }
@@ -0,0 +1,119 @@
1
+ Metadata-Version: 2.4
2
+ Name: depthtensor
3
+ Version: 3.0.0
4
+ Summary: Tensor math and autograd on CPU and CUDA
5
+ Author-email: Hong Ha Le <lehahong1310@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/l-h-ha/DepthTensor
8
+ Project-URL: Bug Tracker, https://github.com/l-h-ha/DepthTensor/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: numpy
16
+ Provides-Extra: cuda
17
+ Requires-Dist: cupy; extra == "cuda"
18
+ Dynamic: license-file
19
+
20
+ # DepthTensor
21
+
22
+ DepthTensor provides broadcasted tensor math, reductions, matrix multiplication, and reverse-mode autodiff. It uses NumPy on CPU and CuPy on CUDA. For neural networks, see [DepthML](https://github.com/l-h-ha/DepthML).
23
+
24
+ DepthTensor supports real-valued tensors. Autograd requires a floating-point dtype.
25
+
26
+ ## Install
27
+
28
+ Use Python 3.10 or later. Pip installs NumPy and builds the C++ extension from source. Install a C++ compiler and Python development headers on Linux, or MSVC and the Windows SDK on Windows.
29
+
30
+ ### CPU
31
+
32
+ ```bash
33
+ python -m pip install depthtensor
34
+ ```
35
+
36
+ ### CPU + CUDA
37
+
38
+ On Linux or Windows, use a supported NVIDIA GPU and a compatible driver. Run `nvidia-smi` to check the CUDA version your driver supports. Choose one install command. [NVIDIA driver check](https://docs.nvidia.com/deploy/nvidia-smi/index.html#cuda-umd-version)
39
+
40
+ | CUDA | Install |
41
+ | --- | --- |
42
+ | 12.x | `python -m pip install depthtensor "cupy-cuda12x[ctk]"` |
43
+ | 13.x | `python -m pip install depthtensor "cupy-cuda13x[ctk]"` |
44
+
45
+ `[ctk]` installs CUDA libraries through pip. Remove `[ctk]` to use an installed CUDA Toolkit. Set `device = "cuda"` in the example. [CuPy installation guide](https://docs.cupy.dev/en/stable/install.html#installing-cupy-from-pypi)
46
+
47
+ `python -m pip install "depthtensor[cuda]"` uses CuPy's source package and requires an installed CUDA Toolkit. Use one CuPy package per environment. [CuPy source builds](https://docs.cupy.dev/en/stable/install.html#installing-cupy-from-source)
48
+
49
+ ## Build from source
50
+
51
+ Install from the repository root.
52
+
53
+ ```bash
54
+ python -m pip install .
55
+ ```
56
+
57
+ Build a wheel in `dist/` with pip.
58
+
59
+ ```bash
60
+ python -m pip wheel . --no-deps --wheel-dir dist
61
+ ```
62
+
63
+ ## Example
64
+
65
+ Minimize the Rosenbrock function with gradient descent.
66
+
67
+ ```python
68
+ import depthtensor as dt
69
+
70
+ device = "cpu"
71
+ x = dt.Tensor([1.2], device=device, requires_grad=True)
72
+ y = dt.Tensor([1.2], device=device, requires_grad=True)
73
+ a = dt.Tensor([1], device=device)
74
+ b = dt.Tensor([100], device=device)
75
+
76
+ lr = 0.001
77
+ for i in range(500):
78
+ loss = (a - x) ** 2 + b * (y - x**2) ** 2
79
+ loss.backward()
80
+ x.data -= lr * x.grad
81
+ y.data -= lr * y.grad
82
+ x.zero_grad()
83
+ y.zero_grad()
84
+
85
+ if i % 10 == 0:
86
+ print(loss.item())
87
+
88
+ print(f"({x.data}, {y.data})")
89
+ ```
90
+
91
+ ## CPU benchmarks
92
+
93
+ Intel i5-11400H, Windows 26200, Python 3.11.15.
94
+ DepthTensor 3.0.0, PyTorch 2.12.1+cpu, TensorFlow 2.21.0, NumPy 2.3.5.
95
+
96
+ Rounded median (min–max) in µs/call.
97
+
98
+ | Tasks | Input shapes | DepthTensor | PyTorch | TensorFlow |
99
+ | --- | --- | ---: | ---: | ---: |
100
+ | Vector add | `1024 each` | 26 (21–41) | **4** (4–12) | 36 (24–66) |
101
+ | Broadcast add | `1024×1024 + 1024` | 1747 (1354–2957) | **481** (312–1024) | 793 (535–932) |
102
+ | ReLU | `1024×1024` | 7961 (6033–9598) | **412** (337–620) | 516 (413–1148) |
103
+ | Row sum | `1024×1024` | 588 (427–800) | 274 (189–467) | **214** (187–384) |
104
+ | Matmul | `512×512 each` | 4192 (3350–5444) | 3210 (3079–3755) | **3077** (2760–4022) |
105
+ | Matmul → ReLU → MSE + backward | `256×128 @ 128×128` | 2255 (1858–3681) | **782** (580–911) | 1832 (1531–2672) |
106
+
107
+ DepthTensor ranked third in all six matmul runs.
108
+
109
+ Run from the repo root in a Python 3.11 venv.
110
+
111
+ ```bash
112
+ python -m pip install --index-url https://download.pytorch.org/whl/cpu "torch==2.12.1+cpu"
113
+ python -m pip install . "tensorflow-cpu==2.21.0" "numpy==2.3.5"
114
+ python benchmarks/run.py --runs 6
115
+ ```
116
+
117
+ ## License
118
+
119
+ [MIT](LICENSE).
@@ -0,0 +1,42 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ setup.py
6
+ csrc/bindings/bind_nn.cpp
7
+ csrc/bindings/main.cpp
8
+ csrc/cpu/nn/activations.cpp
9
+ csrc/include/nn/activations.h
10
+ depthtensor.egg-info/PKG-INFO
11
+ depthtensor.egg-info/SOURCES.txt
12
+ depthtensor.egg-info/dependency_links.txt
13
+ depthtensor.egg-info/requires.txt
14
+ depthtensor.egg-info/top_level.txt
15
+ src/DepthTensor/__init__.py
16
+ src/DepthTensor/tensor.py
17
+ src/DepthTensor/typing.py
18
+ src/DepthTensor/_core/__init__.py
19
+ src/DepthTensor/_core/autograd.py
20
+ src/DepthTensor/_core/exceptions.py
21
+ src/DepthTensor/_core/indexing.py
22
+ src/DepthTensor/_core/output.py
23
+ src/DepthTensor/_core/storage.py
24
+ src/DepthTensor/_core/utils.py
25
+ src/DepthTensor/_core/nn/__init__.py
26
+ src/DepthTensor/_core/nn/_backend/__init__.py
27
+ src/DepthTensor/_core/nn/_backend/activation_functions.py
28
+ src/DepthTensor/_core/nn/functional/__init__.py
29
+ src/DepthTensor/_core/nn/functional/activation_functions.py
30
+ src/DepthTensor/_core/ops/__init__.py
31
+ src/DepthTensor/_core/ops/comparison.py
32
+ src/DepthTensor/_core/ops/creation.py
33
+ src/DepthTensor/_core/ops/elementwise.py
34
+ src/DepthTensor/_core/ops/function.py
35
+ src/DepthTensor/_core/ops/reduction.py
36
+ src/DepthTensor/_core/random/__init__.py
37
+ src/DepthTensor/_core/random/generator.py
38
+ src/DepthTensor/_ext/__init__.pyi
39
+ src/DepthTensor/_ext/nn.pyi
40
+ src/DepthTensor/enum/__init__.py
41
+ src/DepthTensor/enum/initialize_grad.py
42
+ tests/test_env.py
@@ -1,4 +1,4 @@
1
1
  numpy
2
2
 
3
- [gpu]
3
+ [cuda]
4
4
  cupy
@@ -0,0 +1 @@
1
+ depthtensor
@@ -1,29 +1,29 @@
1
1
  [build-system]
2
- requires = ["setuptools>=61.0.0"]
2
+ requires = ["setuptools>=77.0.3", "pybind11>=2.10.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "depthtensor"
7
- version = "2.7.0"
8
- description = "A Hardware-Accelerated Tensor Computation and Autograd Engine"
7
+ version = "3.0.0"
8
+ description = "Tensor math and autograd on CPU and CUDA"
9
9
  readme = "README.md"
10
10
  authors = [
11
- { name = "Le Hong Ha", email = "lehahong1310@gmail.com" }
11
+ { name = "Hong Ha Le", email = "lehahong1310@gmail.com" }
12
12
  ]
13
- license = { file = "LICENSE" }
13
+ license = "MIT"
14
+ license-files = ["LICENSE"]
14
15
  classifiers = [
15
16
  "Programming Language :: Python :: 3",
16
17
  "Topic :: Scientific/Engineering :: Artificial Intelligence",
17
- "License :: OSI Approved :: MIT License",
18
18
  "Operating System :: OS Independent"
19
19
  ]
20
- requires-python = ">=3.8"
20
+ requires-python = ">=3.10"
21
21
  dependencies = [
22
22
  "numpy"
23
23
  ]
24
24
 
25
25
  [project.optional-dependencies]
26
- gpu = [
26
+ cuda = [
27
27
  "cupy"
28
28
  ]
29
29
 
@@ -31,5 +31,5 @@ gpu = [
31
31
  "Homepage" = "https://github.com/l-h-ha/DepthTensor"
32
32
  "Bug Tracker" = "https://github.com/l-h-ha/DepthTensor/issues"
33
33
 
34
- [tool.setuptools.packages.find]
35
- where = ["src"]
34
+ [tool.ruff.lint]
35
+ select = ["E4", "E7", "E9", "F"]
@@ -0,0 +1,37 @@
1
+ from setuptools import setup, Extension, find_namespace_packages
2
+ import pybind11
3
+ import glob
4
+ import os
5
+
6
+ source_package = "depthtensor" if "depthtensor" in os.listdir("src") else "DepthTensor"
7
+ source_packages = find_namespace_packages(
8
+ where="src",
9
+ include=[source_package, f"{source_package}.*"],
10
+ )
11
+ packages = [package.replace(source_package, "depthtensor", 1) for package in source_packages]
12
+
13
+ bindings_src = glob.glob("csrc/bindings/*.cpp")
14
+ cpu_core_src = glob.glob("csrc/cpu/core/*.cpp")
15
+ cpu_nn_src = glob.glob("csrc/cpu/nn/*.cpp")
16
+
17
+ all_sources = bindings_src + cpu_core_src + cpu_nn_src
18
+
19
+ ext_modules = [
20
+ Extension(
21
+ "depthtensor._ext",
22
+ sources=all_sources,
23
+ include_dirs=[
24
+ pybind11.get_include(),
25
+ os.path.abspath("csrc/include"),
26
+ ],
27
+ language="c++",
28
+ extra_compile_args=["-O3", "-Wall", "-shared", "-fPIC"],
29
+ ),
30
+ ]
31
+
32
+ setup(
33
+ packages=packages,
34
+ package_dir={"depthtensor": f"src/{source_package}"},
35
+ package_data={"depthtensor._ext": ["*.pyi"]},
36
+ ext_modules=ext_modules,
37
+ )