newton-vision 1.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 (43) hide show
  1. newton_vision-1.0.0/.gitignore +27 -0
  2. newton_vision-1.0.0/CMakeLists.txt +37 -0
  3. newton_vision-1.0.0/MANIFEST.in +21 -0
  4. newton_vision-1.0.0/PKG-INFO +74 -0
  5. newton_vision-1.0.0/PROGRESS.md +49 -0
  6. newton_vision-1.0.0/README.md +26 -0
  7. newton_vision-1.0.0/benchmarks/bench_layers.py +119 -0
  8. newton_vision-1.0.0/benchmarks/bench_vs_pytorch.py +90 -0
  9. newton_vision-1.0.0/cpp/binding.cpp +314 -0
  10. newton_vision-1.0.0/cpp/cuda_layers.cu +188 -0
  11. newton_vision-1.0.0/cpp/cuda_layers.h +21 -0
  12. newton_vision-1.0.0/cpp/layers.cpp +372 -0
  13. newton_vision-1.0.0/cpp/layers.h +66 -0
  14. newton_vision-1.0.0/docs/autograd_math.md +58 -0
  15. newton_vision-1.0.0/examples/master_showcase.py +160 -0
  16. newton_vision-1.0.0/examples/realtime_stream_demo.py +62 -0
  17. newton_vision-1.0.0/examples/sobel_edge_demo.py +94 -0
  18. newton_vision-1.0.0/examples/train_mnist.py +140 -0
  19. newton_vision-1.0.0/ileriye_d/303/266n/303/274k.txt +263 -0
  20. newton_vision-1.0.0/pyproject.toml +40 -0
  21. newton_vision-1.0.0/python_ref/layers.py +101 -0
  22. newton_vision-1.0.0/python_ref/test_ref.py +43 -0
  23. newton_vision-1.0.0/src/newton_vision/__init__.py +55 -0
  24. newton_vision-1.0.0/src/newton_vision/fluxion.py +5 -0
  25. newton_vision-1.0.0/src/newton_vision/gravity.py +86 -0
  26. newton_vision-1.0.0/src/newton_vision/jit.py +111 -0
  27. newton_vision-1.0.0/src/newton_vision/layers.py +216 -0
  28. newton_vision-1.0.0/src/newton_vision/models/__init__.py +11 -0
  29. newton_vision-1.0.0/src/newton_vision/models/mobilenet.py +99 -0
  30. newton_vision-1.0.0/src/newton_vision/models/resnet.py +82 -0
  31. newton_vision-1.0.0/src/newton_vision/optics.py +23 -0
  32. newton_vision-1.0.0/src/newton_vision/principia.py +30 -0
  33. newton_vision-1.0.0/src/newton_vision/tensor.py +155 -0
  34. newton_vision-1.0.0/src/newton_vision/weights.py +42 -0
  35. newton_vision-1.0.0/stream_model.nv.npz +0 -0
  36. newton_vision-1.0.0/tests/test_autograd.py +91 -0
  37. newton_vision-1.0.0/tests/test_correctness.py +133 -0
  38. newton_vision-1.0.0/tests/test_cpp_core.cpp +70 -0
  39. newton_vision-1.0.0/tests/test_jit.py +75 -0
  40. newton_vision-1.0.0/tests/test_model.nv.npz +0 -0
  41. newton_vision-1.0.0/tests/test_models.py +74 -0
  42. newton_vision-1.0.0/tutorials/mnist_training.py +117 -0
  43. newton_vision-1.0.0/tutorials/train_and_eval_lenet.py +230 -0
@@ -0,0 +1,27 @@
1
+ # Build & Compiled artifacts
2
+ build/
3
+ dist/
4
+ *.egg-info/
5
+ .wheel_tag/
6
+ _core*.pyd
7
+ _core*.so
8
+
9
+ # Python bytecode & cache
10
+ __pycache__/
11
+ *.py[cod]
12
+ *$py.class
13
+ .pytest_cache/
14
+
15
+ # Dataset & Temporary Model Checkpoints
16
+ tutorials/data/
17
+ *.nv
18
+ *.onnx
19
+ *.png
20
+ *.log
21
+
22
+ # IDE & OS
23
+ .vs/
24
+ .vscode/
25
+ .idea/
26
+ .DS_Store
27
+ Thumbs.db
@@ -0,0 +1,37 @@
1
+ cmake_minimum_required(VERSION 3.17)
2
+ project(newton_vision LANGUAGES CXX)
3
+
4
+ set(CMAKE_CXX_STANDARD 17)
5
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
6
+
7
+ find_package(pybind11 CONFIG REQUIRED)
8
+ find_package(OpenMP REQUIRED)
9
+
10
+ include(CheckLanguage)
11
+ check_language(CUDA)
12
+
13
+ if(CMAKE_CUDA_COMPILER)
14
+ enable_language(CUDA)
15
+ set(CMAKE_CUDA_STANDARD 17)
16
+ add_definitions(-DHAS_CUDA)
17
+ pybind11_add_module(_core
18
+ cpp/binding.cpp
19
+ cpp/layers.cpp
20
+ cpp/cuda_layers.cu
21
+ )
22
+ set_property(TARGET _core PROPERTY CUDA_SEPARABLE_COMPILATION ON)
23
+ else()
24
+ pybind11_add_module(_core
25
+ cpp/binding.cpp
26
+ cpp/layers.cpp
27
+ )
28
+ endif()
29
+
30
+ target_include_directories(_core PRIVATE cpp)
31
+ target_link_libraries(_core PRIVATE OpenMP::OpenMP_CXX)
32
+
33
+ if(WIN32 AND MINGW)
34
+ target_link_options(_core PRIVATE -static-libgcc -static-libstdc++)
35
+ endif()
36
+
37
+ install(TARGETS _core DESTINATION newton_vision)
@@ -0,0 +1,21 @@
1
+ include README.md
2
+ include PROGRESS.md
3
+ include CMakeLists.txt
4
+ include pyproject.toml
5
+ recursive-include cpp *.h *.cpp *.cu
6
+ recursive-include src/newton_vision *.py
7
+ recursive-include docs *.md
8
+ recursive-include benchmarks *.py
9
+ recursive-include examples *.py
10
+ recursive-include tests *.py
11
+ recursive-include tutorials *.py
12
+
13
+ global-exclude __pycache__
14
+ global-exclude *.py[cod]
15
+ global-exclude *.nv
16
+ global-exclude *.onnx
17
+ global-exclude *.png
18
+ global-exclude *.log
19
+ prune tutorials/data
20
+ prune build
21
+ prune dist
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.2
2
+ Name: newton-vision
3
+ Version: 1.0.0
4
+ Summary: High-Performance Computer Vision & Deep Learning Framework in C++ & CUDA with PyTorch Parity
5
+ Keywords: deep-learning,computer-vision,cuda,autograd,cnn,resnet,mobilenet,cpp
6
+ Author-Email: newton-vision Core Team <info@newton-vision.org>
7
+ Classifier: Development Status :: 5 - Production/Stable
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
19
+ Project-URL: Homepage, https://github.com/onur/newton-vision
20
+ Project-URL: Documentation, https://github.com/onur/newton-vision/tree/master/docs
21
+ Project-URL: Repository, https://github.com/onur/newton-vision.git
22
+ Requires-Python: >=3.9
23
+ Requires-Dist: numpy>=1.20.0
24
+ Description-Content-Type: text/markdown
25
+
26
+ # newton-vision — İlerleme & Devam Noktası
27
+
28
+ > Bu dosya oturumlarda kaldığımız yerden devam edebilmek için **tek doğruluk kaynağıdır**. Her oturumda güncelle.
29
+ > Özet: sıfırdan, sürdürülebilir, pybind11'li bir görüntü/CNN çekirdeği yazıyoruz.
30
+
31
+ > **⭐ DEVAM NOKTASI:** **v1.0.0 RESMİ SÜRÜM & PYPI DAĞITIM PAKETLERİ TAMAMLANDI!**
32
+ > 1. Gerçek MNIST verisi üzerinde LeNet evrişimsel sinir ağı eğitildi (%91.6 Eğitim, %86.6 Test Doğruluğu) ve model `tutorials/lenet_mnist_v1.nv` checkpoint dosyası olarak kaydedildi.
33
+ > 2. PyPI ikili tekerlek (`dist/newton_vision-1.0.0-cp313-cp313-win_amd64.whl`) ve kaynak dağıtım paketi (`dist/newton_vision-1.0.0.tar.gz`) derlendi.
34
+
35
+ Yol: `C:\Users\onur_\Desktop\newton-vision` (Windows 11, git repo, branch `master`)
36
+
37
+ ---
38
+
39
+ ## 🎯 Proje Dizin Yapısı (Open Source Production Release)
40
+
41
+ ```
42
+ newton-vision/
43
+ ├── dist/ # PyPI Dağıtım Paketleri (.whl & .tar.gz)
44
+ ├── cpp/ # C++ & CUDA Katman Çekirdeği (im2col, GEMM, OpenMP, NVCC)
45
+ ├── docs/ # Mimari ve Akademik Matematik Dokümantasyonu (docs/autograd_math.md)
46
+ ├── benchmarks/ # PyTorch vs newton-vision Yan Yana Karşılaştırma Testleri
47
+ ├── examples/ # Canlı Görsel, Sobel Filtreleme ve Master Showcase Demosu
48
+ ├── tests/ # Otomatik Birim ve Parite Testleri (100% PASS)
49
+ ├── tutorials/ # Uçtan Uca Model Eğitimi & Checkpoint (train_and_eval_lenet.py, lenet_mnist_v1.nv)
50
+ └── src/newton_vision/ # Ana Python Paketi (v1.0.0 - optics, fluxion, gravity, principia, models, weights, jit)
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 📦 1. PyPI Dağıtım Paketleri (`dist/`)
56
+
57
+ - `dist/newton_vision-1.0.0-cp313-cp313-win_amd64.whl` (Binary Wheel Package)
58
+ - `dist/newton_vision-1.0.0.tar.gz` (Source Package)
59
+
60
+ Paketi yüklemek için:
61
+ ```bash
62
+ pip install dist/newton_vision-1.0.0-cp313-cp313-win_amd64.whl
63
+ ```
64
+
65
+ ---
66
+
67
+ ## 🧪 2. Model Eğitimi & Değerlendirme Sonuçları (`tutorials/train_and_eval_lenet.py`)
68
+
69
+ - **Eğitim Verisi:** 60,000 Örnek | **Test Verisi:** 10,000 Örnek
70
+ - **Model:** LeNet Classifier (`Conv2d` ➜ `ReLU` ➜ `MaxPool2d` ➜ `Conv2d` ➜ `Linear` 120 ➜ `Linear` 84 ➜ `Linear` 10)
71
+ - **Loss:** `CrossEntropyLoss` | **Optimizer:** `Adam`
72
+ - **Eğitim Başarımı:** %91.6 Accuracy (Loss: 0.2590)
73
+ - **🏆 TEST KÜMESİ DOĞRULUĞU:** **%86.6 Accuracy**
74
+ - **Kaydedilen Model Checkpoint:** `tutorials/lenet_mnist_v1.nv`
@@ -0,0 +1,49 @@
1
+ # newton-vision — İlerleme & Devam Noktası
2
+
3
+ > Bu dosya oturumlarda kaldığımız yerden devam edebilmek için **tek doğruluk kaynağıdır**. Her oturumda güncelle.
4
+ > Özet: sıfırdan, sürdürülebilir, pybind11'li bir görüntü/CNN çekirdeği yazıyoruz.
5
+
6
+ > **⭐ DEVAM NOKTASI:** **v1.0.0 RESMİ SÜRÜM & PYPI DAĞITIM PAKETLERİ TAMAMLANDI!**
7
+ > 1. Gerçek MNIST verisi üzerinde LeNet evrişimsel sinir ağı eğitildi (%91.6 Eğitim, %86.6 Test Doğruluğu) ve model `tutorials/lenet_mnist_v1.nv` checkpoint dosyası olarak kaydedildi.
8
+ > 2. PyPI ikili tekerlek (`dist/newton_vision-1.0.0-cp313-cp313-win_amd64.whl`) ve kaynak dağıtım paketi (`dist/newton_vision-1.0.0.tar.gz`) derlendi.
9
+
10
+ Yol: `C:\Users\onur_\Desktop\newton-vision` (Windows 11, git repo, branch `master`)
11
+
12
+ ---
13
+
14
+ ## 🎯 Proje Dizin Yapısı (Open Source Production Release)
15
+
16
+ ```
17
+ newton-vision/
18
+ ├── dist/ # PyPI Dağıtım Paketleri (.whl & .tar.gz)
19
+ ├── cpp/ # C++ & CUDA Katman Çekirdeği (im2col, GEMM, OpenMP, NVCC)
20
+ ├── docs/ # Mimari ve Akademik Matematik Dokümantasyonu (docs/autograd_math.md)
21
+ ├── benchmarks/ # PyTorch vs newton-vision Yan Yana Karşılaştırma Testleri
22
+ ├── examples/ # Canlı Görsel, Sobel Filtreleme ve Master Showcase Demosu
23
+ ├── tests/ # Otomatik Birim ve Parite Testleri (100% PASS)
24
+ ├── tutorials/ # Uçtan Uca Model Eğitimi & Checkpoint (train_and_eval_lenet.py, lenet_mnist_v1.nv)
25
+ └── src/newton_vision/ # Ana Python Paketi (v1.0.0 - optics, fluxion, gravity, principia, models, weights, jit)
26
+ ```
27
+
28
+ ---
29
+
30
+ ## 📦 1. PyPI Dağıtım Paketleri (`dist/`)
31
+
32
+ - `dist/newton_vision-1.0.0-cp313-cp313-win_amd64.whl` (Binary Wheel Package)
33
+ - `dist/newton_vision-1.0.0.tar.gz` (Source Package)
34
+
35
+ Paketi yüklemek için:
36
+ ```bash
37
+ pip install dist/newton_vision-1.0.0-cp313-cp313-win_amd64.whl
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 🧪 2. Model Eğitimi & Değerlendirme Sonuçları (`tutorials/train_and_eval_lenet.py`)
43
+
44
+ - **Eğitim Verisi:** 60,000 Örnek | **Test Verisi:** 10,000 Örnek
45
+ - **Model:** LeNet Classifier (`Conv2d` ➜ `ReLU` ➜ `MaxPool2d` ➜ `Conv2d` ➜ `Linear` 120 ➜ `Linear` 84 ➜ `Linear` 10)
46
+ - **Loss:** `CrossEntropyLoss` | **Optimizer:** `Adam`
47
+ - **Eğitim Başarımı:** %91.6 Accuracy (Loss: 0.2590)
48
+ - **🏆 TEST KÜMESİ DOĞRULUĞU:** **%86.6 Accuracy**
49
+ - **Kaydedilen Model Checkpoint:** `tutorials/lenet_mnist_v1.nv`
@@ -0,0 +1,26 @@
1
+ # newton-vision
2
+
3
+ Sıfırdan, sürdürülebilir bir görüntü/CNN işleme çekirdeği. Saf Python → C++:
4
+
5
+ - **C++ çekirdek** (`cpp/`): conv2d, ReLU, maxpool2d — GCC 15 ile derlenir.
6
+ - **pybind11 binding**: `import newton_vision` diye çağrılır.
7
+ - **Saf Python referans** (`python_ref/`): doğruluk için altın standart.
8
+ - **Test + benchmark**: C++ çıktısı saf Python ile eşit mi? Hız kazancı ne kadar?
9
+
10
+ ## Hedef Yol Haritası
11
+ - `v0.1` — C++ conv2d + relu + maxpool, pybind11, standart build & doğruluk testi (✅ Tamamlandı)
12
+ - `v0.2` — `im2col + GEMM` C++ hız katmanı & ek katmanlar (AvgPool2d, BatchNorm2d vb.)
13
+ - `v0.3` — autograd / backward pass (`fluxion` türev motoru)
14
+
15
+ ## Kurulum ve Kullanım
16
+
17
+ ```bash
18
+ # Standart paket kurulumu (scikit-build-core + pybind11)
19
+ pip install .
20
+
21
+ # Test
22
+ python -c "from newton_vision import Conv2d, ReLU, MaxPool2d; print('newton-vision hazir!')"
23
+ ```
24
+
25
+ ---
26
+ Birlikte yazılmıştır. 🤝
@@ -0,0 +1,119 @@
1
+ """Benchmark: C++ pybind11 Çekirdeği vs Saf Python Referansı.
2
+
3
+ Performans ve hız karşılaştırmasını (Speedup factor) ölçer.
4
+ """
5
+
6
+ from __future__ import annotations
7
+ import sys
8
+ import os
9
+ import time
10
+ import numpy as np
11
+
12
+ PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
13
+ sys.path.insert(0, os.path.join(PROJECT_ROOT, "python_ref"))
14
+
15
+ import layers as ref
16
+ import newton_vision._core as _core
17
+
18
+
19
+ def benchmark_conv2d():
20
+ print("\n[BENCHMARK] Conv2D (N=4, C_in=16, H=64, W=64 -> C_out=32, 3x3)")
21
+ np.random.seed(42)
22
+
23
+ x = np.random.randn(4, 16, 64, 64).astype(np.float32)
24
+ w = np.random.randn(32, 16, 3, 3).astype(np.float32)
25
+ bias = np.random.randn(32).astype(np.float32)
26
+
27
+ warmup = 3
28
+ iters = 15
29
+
30
+ # Warmup
31
+ for _ in range(warmup):
32
+ _ = ref.conv2d(x, w, bias=bias, stride=1, padding=1)
33
+ _ = _core.conv2d(x, w, bias=bias, stride=1, padding=1)
34
+
35
+ # Benchmark Ref
36
+ t0 = time.perf_counter()
37
+ for _ in range(iters):
38
+ _ = ref.conv2d(x, w, bias=bias, stride=1, padding=1)
39
+ t_ref = (time.perf_counter() - t0) / iters
40
+
41
+ # Benchmark C++
42
+ t0 = time.perf_counter()
43
+ for _ in range(iters):
44
+ _ = _core.conv2d(x, w, bias=bias, stride=1, padding=1)
45
+ t_cpp = (time.perf_counter() - t0) / iters
46
+
47
+ speedup = t_ref / t_cpp if t_cpp > 0 else 0
48
+ print(f" Python Ref : {t_ref * 1000:.2f} ms / iter")
49
+ print(f" C++ Naive : {t_cpp * 1000:.2f} ms / iter")
50
+ print(f" 🚀 Speedup : {speedup:.2f}x daha hızlı!")
51
+
52
+
53
+ def benchmark_relu():
54
+ print("\n[BENCHMARK] ReLU (16 x 64 x 128 x 128)")
55
+ np.random.seed(42)
56
+
57
+ x = np.random.randn(16, 64, 128, 128).astype(np.float32)
58
+ warmup = 5
59
+ iters = 30
60
+
61
+ for _ in range(warmup):
62
+ _ = ref.relu(x)
63
+ _ = _core.relu(x)
64
+
65
+ t0 = time.perf_counter()
66
+ for _ in range(iters):
67
+ _ = ref.relu(x)
68
+ t_ref = (time.perf_counter() - t0) / iters
69
+
70
+ t0 = time.perf_counter()
71
+ for _ in range(iters):
72
+ _ = _core.relu(x)
73
+ t_cpp = (time.perf_counter() - t0) / iters
74
+
75
+ speedup = t_ref / t_cpp if t_cpp > 0 else 0
76
+ print(f" Python Ref : {t_ref * 1000:.2f} ms / iter")
77
+ print(f" C++ Core : {t_cpp * 1000:.2f} ms / iter")
78
+ print(f" 🚀 Speedup : {speedup:.2f}x daha hızlı!")
79
+
80
+
81
+ def benchmark_maxpool2d():
82
+ print("\n[BENCHMARK] MaxPool2D (N=8, C=32, H=64, W=64, k=2, s=2)")
83
+ np.random.seed(42)
84
+
85
+ x = np.random.randn(8, 32, 64, 64).astype(np.float32)
86
+ warmup = 3
87
+ iters = 20
88
+
89
+ for _ in range(warmup):
90
+ _ = ref.maxpool2d(x, kernel_size=2, stride=2)
91
+ _ = _core.maxpool2d(x, kernel_size=2, stride=2)
92
+
93
+ t0 = time.perf_counter()
94
+ for _ in range(iters):
95
+ _ = ref.maxpool2d(x, kernel_size=2, stride=2)
96
+ t_ref = (time.perf_counter() - t0) / iters
97
+
98
+ t0 = time.perf_counter()
99
+ for _ in range(iters):
100
+ _ = _core.maxpool2d(x, kernel_size=2, stride=2)
101
+ t_cpp = (time.perf_counter() - t0) / iters
102
+
103
+ speedup = t_ref / t_cpp if t_cpp > 0 else 0
104
+ print(f" Python Ref : {t_ref * 1000:.2f} ms / iter")
105
+ print(f" C++ Naive : {t_cpp * 1000:.2f} ms / iter")
106
+ print(f" 🚀 Speedup : {speedup:.2f}x daha hızlı!")
107
+
108
+
109
+ def main():
110
+ print("==========================================")
111
+ print("newton-vision: Performans Benchmark")
112
+ print("==========================================")
113
+ benchmark_conv2d()
114
+ benchmark_relu()
115
+ benchmark_maxpool2d()
116
+
117
+
118
+ if __name__ == "__main__":
119
+ main()
@@ -0,0 +1,90 @@
1
+ """newton-vision vs PyTorch 2.6.0 Yan Yana Performans Benchmark Testi (benchmarks/bench_vs_pytorch.py).
2
+
3
+ newton-vision C++ OpenMP çekirdeği ile PyTorch CPU motorunun evrişim (Conv2d)
4
+ gecikmesini (latency ms) ve saniye başı kare işleme hızını (FPS) doğrudan karşılaştırır.
5
+ """
6
+
7
+ from __future__ import annotations
8
+ import time
9
+ import numpy as np
10
+ import torch
11
+ import torch.nn as nn
12
+ import newton_vision as nv
13
+
14
+
15
+ def benchmark_conv2d(batch_size=4, in_channels=16, out_channels=32, H=64, W=64, kernel_size=3, padding=1, num_runs=50):
16
+ print(f"\n--- Conv2D Benchmark: input=({batch_size}, {in_channels}, {H}, {W}), kernel={kernel_size}x{kernel_size}, runs={num_runs} ---")
17
+
18
+ # Input & Weight data
19
+ x_np = np.random.randn(batch_size, in_channels, H, W).astype(np.float32)
20
+
21
+ # 1. newton-vision C++ OpenMP Engine
22
+ nv_conv = nv.Conv2d(in_channels, out_channels, kernel_size, padding=padding)
23
+
24
+ # Warmup
25
+ _ = nv_conv(x_np)
26
+
27
+ start = time.perf_counter()
28
+ for _ in range(num_runs):
29
+ _ = nv_conv(x_np)
30
+ end = time.perf_counter()
31
+ nv_total_time = end - start
32
+ nv_avg_ms = (nv_total_time / num_runs) * 1000.0
33
+ nv_fps = (batch_size * num_runs) / nv_total_time
34
+
35
+ # 2. PyTorch 2.6 CPU Engine
36
+ torch_x = torch.from_numpy(x_np)
37
+ torch_conv = nn.Conv2d(in_channels, out_channels, kernel_size, padding=padding)
38
+ torch_conv.weight.data = torch.from_numpy(nv_conv.w.data)
39
+ if nv_conv.bias is not None:
40
+ torch_conv.bias.data = torch.from_numpy(nv_conv.bias.data)
41
+
42
+ # Warmup
43
+ with torch.no_grad():
44
+ _ = torch_conv(torch_x)
45
+
46
+ start = time.perf_counter()
47
+ with torch.no_grad():
48
+ for _ in range(num_runs):
49
+ _ = torch_conv(torch_x)
50
+ end = time.perf_counter()
51
+ torch_total_time = end - start
52
+ torch_avg_ms = (torch_total_time / num_runs) * 1000.0
53
+ torch_fps = (batch_size * num_runs) / torch_total_time
54
+
55
+ print(f" • newton-vision C++ Engine : {nv_avg_ms:6.2f} ms / batch | Hız: {nv_fps:7.1f} FPS")
56
+ print(f" • PyTorch 2.6 CPU Engine : {torch_avg_ms:6.2f} ms / batch | Hız: {torch_fps:7.1f} FPS")
57
+
58
+ speedup = torch_avg_ms / nv_avg_ms
59
+ if speedup >= 1.0:
60
+ print(f" 🚀 newton-vision PyTorch'a kıyasla {speedup:.2f}x daha hızlı!")
61
+ else:
62
+ print(f" 📊 PyTorch newton-vision'a kıyasla {1.0/speedup:.2f}x daha hızlı.")
63
+
64
+ return nv_avg_ms, torch_avg_ms
65
+
66
+
67
+ def main():
68
+ print("===============================================================")
69
+ print(" newton-vision vs PyTorch 2.6.0 BENCHMARK RAPORU ")
70
+ print("===============================================================")
71
+ print(f"PyTorch Sürümü : {torch.__version__}")
72
+ print(f"newton-vision : v0.6.0 (C++ im2col + GEMM + OpenMP)")
73
+
74
+ b1_nv, b1_torch = benchmark_conv2d(batch_size=1, in_channels=3, out_channels=16, H=128, W=128)
75
+ b2_nv, b2_torch = benchmark_conv2d(batch_size=8, in_channels=16, out_channels=32, H=64, W=64)
76
+ b3_nv, b3_torch = benchmark_conv2d(batch_size=16, in_channels=32, out_channels=64, H=32, W=32)
77
+
78
+ print("\n===============================================================")
79
+ print(" ÖZET TABLO ")
80
+ print("===============================================================")
81
+ print("| Test Senaryosu | newton-vision | PyTorch 2.6 CPU |")
82
+ print("|-----------------------------|---------------|-----------------|")
83
+ print(f"| Batch=1 (128x128 3->16 ch) | {b1_nv:6.2f} ms | {b1_torch:6.2f} ms |")
84
+ print(f"| Batch=8 (64x64 16->32 ch) | {b2_nv:6.2f} ms | {b2_torch:6.2f} ms |")
85
+ print(f"| Batch=16 (32x32 32->64 ch) | {b3_nv:6.2f} ms | {b3_torch:6.2f} ms |")
86
+ print("===============================================================")
87
+
88
+
89
+ if __name__ == "__main__":
90
+ main()