tensorc 0.10.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.
@@ -0,0 +1,5 @@
1
+ # The vendored C core must ship inside the sdist so the wheel can be
2
+ # built from it on any machine (pip builds wheels from the sdist).
3
+ recursive-include tensorc/core *.c *.h
4
+ include README.md
5
+ include sync_core.sh
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.4
2
+ Name: tensorc
3
+ Version: 0.10.0
4
+ Summary: Neural network framework in C11 with autograd, callable from Python
5
+ Author: Carlos Guedea
6
+ License: Apache-2.0
7
+ Keywords: neural-network,autograd,conv2d,c11
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: C
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+
16
+ # tensorc (Python)
17
+
18
+ Bindings de Python para [TensorC](../README.md): el núcleo numérico es la
19
+ biblioteca en C11 (autograd, tensores N-dimensionales, Conv2D con
20
+ stride/padding, max pooling, softmax/cross-entropy, SGD y Adam); este
21
+ paquete solo expone esa funcionalidad a Python mediante una extensión
22
+ CPython escrita en C.
23
+
24
+ ## Uso
25
+
26
+ ```python
27
+ import tensorc
28
+
29
+ x = tensorc.Tensor([1, 2, 3, 4], shape=(2, 2), requires_grad=True)
30
+ w = tensorc.Tensor([1.0, 0.0, 0.0, 1.0], shape=(2, 2), requires_grad=True)
31
+ loss = x.matmul(w).relu().sum()
32
+ loss.backward()
33
+ x.sgd_step(0.01)
34
+
35
+ capa = tensorc.Conv2DLayer(1, 8, 3, 3, stride=(1, 1), padding=(1, 1), seed=42)
36
+ features = capa.forward(imagen) # conv + sesgo, con autograd
37
+ ```
38
+
39
+ ## Compilar e instalar en local
40
+
41
+ Requisitos: Python 3.9+ con cabeceras de desarrollo (`python3-dev` en
42
+ Linux, Python de Homebrew en macOS ya las incluye).
43
+
44
+ ```sh
45
+ python3 -m pip install ./python
46
+ ```
47
+
48
+ ## Publicar en PyPI
49
+
50
+ 1. Genera una distribución de código fuente y, si puedes, ruedas
51
+ precompiladas con [cibuildwheel](https://cibuildwheel.readthedocs.io/)
52
+ para macOS/Linux/Windows:
53
+
54
+ ```sh
55
+ python3 -m pip install build cibuildwheel twine
56
+ cd python
57
+ python3 -m build # sdist + wheel de la plataforma actual
58
+ ```
59
+
60
+ 2. Sube el paquete (necesitas cuenta en PyPI y un token):
61
+
62
+ ```sh
63
+ python3 -m twine upload dist/*
64
+ ```
65
+
66
+ Después cualquiera puede instalarlo con `pip install tensorc`.
67
+
68
+ ## Diseño
69
+
70
+ - `tensorc/_tensorc.c` — extensión CPython (C11). Convierte entre objetos
71
+ Python y `tc_tensor_nd`; no contiene matemáticas.
72
+ - `minitf.c` / `ndtensor.c` — el núcleo en C, idéntico al que usa CMake.
73
+ - En macOS se enlaza Apple Accelerate con la misma ruta im2col+GEMM que el
74
+ build de CMake; en Linux/Windows se usa el backend genérico.
@@ -0,0 +1,59 @@
1
+ # tensorc (Python)
2
+
3
+ Bindings de Python para [TensorC](../README.md): el núcleo numérico es la
4
+ biblioteca en C11 (autograd, tensores N-dimensionales, Conv2D con
5
+ stride/padding, max pooling, softmax/cross-entropy, SGD y Adam); este
6
+ paquete solo expone esa funcionalidad a Python mediante una extensión
7
+ CPython escrita en C.
8
+
9
+ ## Uso
10
+
11
+ ```python
12
+ import tensorc
13
+
14
+ x = tensorc.Tensor([1, 2, 3, 4], shape=(2, 2), requires_grad=True)
15
+ w = tensorc.Tensor([1.0, 0.0, 0.0, 1.0], shape=(2, 2), requires_grad=True)
16
+ loss = x.matmul(w).relu().sum()
17
+ loss.backward()
18
+ x.sgd_step(0.01)
19
+
20
+ capa = tensorc.Conv2DLayer(1, 8, 3, 3, stride=(1, 1), padding=(1, 1), seed=42)
21
+ features = capa.forward(imagen) # conv + sesgo, con autograd
22
+ ```
23
+
24
+ ## Compilar e instalar en local
25
+
26
+ Requisitos: Python 3.9+ con cabeceras de desarrollo (`python3-dev` en
27
+ Linux, Python de Homebrew en macOS ya las incluye).
28
+
29
+ ```sh
30
+ python3 -m pip install ./python
31
+ ```
32
+
33
+ ## Publicar en PyPI
34
+
35
+ 1. Genera una distribución de código fuente y, si puedes, ruedas
36
+ precompiladas con [cibuildwheel](https://cibuildwheel.readthedocs.io/)
37
+ para macOS/Linux/Windows:
38
+
39
+ ```sh
40
+ python3 -m pip install build cibuildwheel twine
41
+ cd python
42
+ python3 -m build # sdist + wheel de la plataforma actual
43
+ ```
44
+
45
+ 2. Sube el paquete (necesitas cuenta en PyPI y un token):
46
+
47
+ ```sh
48
+ python3 -m twine upload dist/*
49
+ ```
50
+
51
+ Después cualquiera puede instalarlo con `pip install tensorc`.
52
+
53
+ ## Diseño
54
+
55
+ - `tensorc/_tensorc.c` — extensión CPython (C11). Convierte entre objetos
56
+ Python y `tc_tensor_nd`; no contiene matemáticas.
57
+ - `minitf.c` / `ndtensor.c` — el núcleo en C, idéntico al que usa CMake.
58
+ - En macOS se enlaza Apple Accelerate con la misma ruta im2col+GEMM que el
59
+ build de CMake; en Linux/Windows se usa el backend genérico.
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tensorc"
7
+ version = "0.10.0"
8
+ description = "Neural network framework in C11 with autograd, callable from Python"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [{ name = "Carlos Guedea" }]
13
+ keywords = ["neural-network", "autograd", "conv2d", "c11"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: C",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: Apache Software License",
19
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
20
+ ]
21
+
22
+ [tool.setuptools]
23
+ packages = ["tensorc"]
24
+
25
+ [tool.setuptools.package-data]
26
+ tensorc = ["*.pyi"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,38 @@
1
+ """Build configuration for the tensorc Python package.
2
+
3
+ Compiles the vendored C11 core (tensorc/core/minitf.c + ndtensor.c,
4
+ mirrors of the repository root) together with the CPython extension into a
5
+ single native module. On macOS it links Apple Accelerate, mirroring the
6
+ CMake build. Refresh the vendored core with python/sync_core.sh after
7
+ changing the C sources.
8
+ """
9
+ import sys
10
+
11
+ from setuptools import Extension, setup
12
+
13
+ extra_compile_args = ["-O3", "-std=c11"]
14
+ extra_link_args = []
15
+ define_macros = []
16
+ libraries = []
17
+ if sys.platform == "darwin":
18
+ define_macros.append(("TENSORC_HAS_ACCELERATE", "1"))
19
+ define_macros.append(("ACCELERATE_NEW_LAPACK", "1"))
20
+ extra_link_args.extend(["-framework", "Accelerate"])
21
+ else:
22
+ libraries.append("m")
23
+
24
+ extension = Extension(
25
+ "tensorc._tensorc",
26
+ sources=[
27
+ "tensorc/core/minitf.c",
28
+ "tensorc/core/ndtensor.c",
29
+ "tensorc/_tensorc.c",
30
+ ],
31
+ include_dirs=["tensorc/core/include", "tensorc/core"],
32
+ define_macros=define_macros,
33
+ extra_compile_args=extra_compile_args,
34
+ extra_link_args=extra_link_args,
35
+ libraries=libraries,
36
+ )
37
+
38
+ setup(ext_modules=[extension])
@@ -0,0 +1,11 @@
1
+ #!/bin/sh
2
+ # Refresca el núcleo C vendorizado en python/tensorc/core/ desde la raíz
3
+ # del repositorio. Ejecutar tras modificar minitf.c, ndtensor.c o los
4
+ # headers públicos, antes de publicar el paquete Python.
5
+ set -e
6
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
7
+ PY="$ROOT/python/tensorc/core"
8
+ cp "$ROOT/minitf.c" "$ROOT/ndtensor.c" "$ROOT/minitf.h" "$PY/"
9
+ cp "$ROOT/include/tensorc/ndtensor.h" "$ROOT/include/tensorc/tensorc.h" \
10
+ "$PY/include/tensorc/"
11
+ echo "núcleo sincronizado en python/tensorc/core/"
@@ -0,0 +1,12 @@
1
+ """TensorC: neural network framework written in C11, with autograd.
2
+
3
+ The numerical core is a C library; this package is a thin CPython
4
+ extension that wraps it. Tensors keep their parents alive automatically,
5
+ so ``backward()`` can be called from any scalar loss.
6
+ """
7
+
8
+ from ._tensorc import Adam, Conv2DLayer, Tensor
9
+
10
+ __version__ = "0.10.0"
11
+
12
+ __all__ = ["Tensor", "Conv2DLayer", "Adam", "__version__"]