neuralforge-ml 0.9.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 (101) hide show
  1. neuralforge_ml-0.9.0/MANIFEST.in +2 -0
  2. neuralforge_ml-0.9.0/PKG-INFO +17 -0
  3. neuralforge_ml-0.9.0/neuralforge/_C/__init__.py +1 -0
  4. neuralforge_ml-0.9.0/neuralforge/_C/_ops.pyi +6 -0
  5. neuralforge_ml-0.9.0/neuralforge/__init__.py +6 -0
  6. neuralforge_ml-0.9.0/neuralforge/core/__init__.py +6 -0
  7. neuralforge_ml-0.9.0/neuralforge/core/autograd.py +29 -0
  8. neuralforge_ml-0.9.0/neuralforge/core/device.py +24 -0
  9. neuralforge_ml-0.9.0/neuralforge/core/dtype.py +34 -0
  10. neuralforge_ml-0.9.0/neuralforge/core/memory.py +27 -0
  11. neuralforge_ml-0.9.0/neuralforge/core/ops/__init__.py +6 -0
  12. neuralforge_ml-0.9.0/neuralforge/core/ops/comparison_ops.py +34 -0
  13. neuralforge_ml-0.9.0/neuralforge/core/ops/fft_ops.py +24 -0
  14. neuralforge_ml-0.9.0/neuralforge/core/ops/linalg_ops.py +34 -0
  15. neuralforge_ml-0.9.0/neuralforge/core/ops/math_ops.py +44 -0
  16. neuralforge_ml-0.9.0/neuralforge/core/ops/reduction_ops.py +34 -0
  17. neuralforge_ml-0.9.0/neuralforge/core/tensor.py +47 -0
  18. neuralforge_ml-0.9.0/neuralforge/cuda/__init__.py +5 -0
  19. neuralforge_ml-0.9.0/neuralforge/cuda/amp.py +19 -0
  20. neuralforge_ml-0.9.0/neuralforge/cuda/graphs.py +22 -0
  21. neuralforge_ml-0.9.0/neuralforge/cuda/memory.py +24 -0
  22. neuralforge_ml-0.9.0/neuralforge/cuda/streams.py +19 -0
  23. neuralforge_ml-0.9.0/neuralforge/data/__init__.py +5 -0
  24. neuralforge_ml-0.9.0/neuralforge/data/collate.py +9 -0
  25. neuralforge_ml-0.9.0/neuralforge/data/dataloader.py +24 -0
  26. neuralforge_ml-0.9.0/neuralforge/data/dataset.py +19 -0
  27. neuralforge_ml-0.9.0/neuralforge/data/sampler.py +22 -0
  28. neuralforge_ml-0.9.0/neuralforge/data/transforms/__init__.py +4 -0
  29. neuralforge_ml-0.9.0/neuralforge/data/transforms/audio.py +19 -0
  30. neuralforge_ml-0.9.0/neuralforge/data/transforms/image.py +19 -0
  31. neuralforge_ml-0.9.0/neuralforge/data/transforms/text.py +19 -0
  32. neuralforge_ml-0.9.0/neuralforge/distributed/__init__.py +7 -0
  33. neuralforge_ml-0.9.0/neuralforge/distributed/all_reduce.py +17 -0
  34. neuralforge_ml-0.9.0/neuralforge/distributed/backend.py +18 -0
  35. neuralforge_ml-0.9.0/neuralforge/distributed/broadcast.py +17 -0
  36. neuralforge_ml-0.9.0/neuralforge/distributed/fsdp.py +17 -0
  37. neuralforge_ml-0.9.0/neuralforge/distributed/pipeline.py +16 -0
  38. neuralforge_ml-0.9.0/neuralforge/distributed/process_group.py +16 -0
  39. neuralforge_ml-0.9.0/neuralforge/hub/__init__.py +5 -0
  40. neuralforge_ml-0.9.0/neuralforge/hub/cache.py +15 -0
  41. neuralforge_ml-0.9.0/neuralforge/hub/download.py +11 -0
  42. neuralforge_ml-0.9.0/neuralforge/hub/registry.py +14 -0
  43. neuralforge_ml-0.9.0/neuralforge/hub/upload.py +9 -0
  44. neuralforge_ml-0.9.0/neuralforge/nn/__init__.py +4 -0
  45. neuralforge_ml-0.9.0/neuralforge/nn/functional.py +77 -0
  46. neuralforge_ml-0.9.0/neuralforge/nn/layers/__init__.py +11 -0
  47. neuralforge_ml-0.9.0/neuralforge/nn/layers/activation.py +21 -0
  48. neuralforge_ml-0.9.0/neuralforge/nn/layers/attention.py +23 -0
  49. neuralforge_ml-0.9.0/neuralforge/nn/layers/conv.py +25 -0
  50. neuralforge_ml-0.9.0/neuralforge/nn/layers/dropout.py +21 -0
  51. neuralforge_ml-0.9.0/neuralforge/nn/layers/embedding.py +22 -0
  52. neuralforge_ml-0.9.0/neuralforge/nn/layers/linear.py +23 -0
  53. neuralforge_ml-0.9.0/neuralforge/nn/layers/normalization.py +22 -0
  54. neuralforge_ml-0.9.0/neuralforge/nn/layers/pooling.py +22 -0
  55. neuralforge_ml-0.9.0/neuralforge/nn/layers/recurrent.py +24 -0
  56. neuralforge_ml-0.9.0/neuralforge/nn/layers/transformer.py +24 -0
  57. neuralforge_ml-0.9.0/neuralforge/nn/loss/__init__.py +6 -0
  58. neuralforge_ml-0.9.0/neuralforge/nn/loss/bce.py +19 -0
  59. neuralforge_ml-0.9.0/neuralforge/nn/loss/cross_entropy.py +19 -0
  60. neuralforge_ml-0.9.0/neuralforge/nn/loss/focal.py +19 -0
  61. neuralforge_ml-0.9.0/neuralforge/nn/loss/mse.py +19 -0
  62. neuralforge_ml-0.9.0/neuralforge/nn/loss/triplet.py +19 -0
  63. neuralforge_ml-0.9.0/neuralforge/nn/module.py +47 -0
  64. neuralforge_ml-0.9.0/neuralforge/nn/parameter.py +22 -0
  65. neuralforge_ml-0.9.0/neuralforge/optim/__init__.py +8 -0
  66. neuralforge_ml-0.9.0/neuralforge/optim/adam.py +22 -0
  67. neuralforge_ml-0.9.0/neuralforge/optim/adamw.py +22 -0
  68. neuralforge_ml-0.9.0/neuralforge/optim/grad_scaler.py +25 -0
  69. neuralforge_ml-0.9.0/neuralforge/optim/lr_scheduler.py +19 -0
  70. neuralforge_ml-0.9.0/neuralforge/optim/optimizer.py +22 -0
  71. neuralforge_ml-0.9.0/neuralforge/optim/rmsprop.py +22 -0
  72. neuralforge_ml-0.9.0/neuralforge/optim/sgd.py +22 -0
  73. neuralforge_ml-0.9.0/neuralforge/profiler/__init__.py +4 -0
  74. neuralforge_ml-0.9.0/neuralforge/profiler/export.py +9 -0
  75. neuralforge_ml-0.9.0/neuralforge/profiler/memory_profiler.py +19 -0
  76. neuralforge_ml-0.9.0/neuralforge/profiler/trace.py +22 -0
  77. neuralforge_ml-0.9.0/neuralforge/serialization/__init__.py +4 -0
  78. neuralforge_ml-0.9.0/neuralforge/serialization/formats.py +14 -0
  79. neuralforge_ml-0.9.0/neuralforge/serialization/load.py +11 -0
  80. neuralforge_ml-0.9.0/neuralforge/serialization/save.py +18 -0
  81. neuralforge_ml-0.9.0/neuralforge/utils/__init__.py +5 -0
  82. neuralforge_ml-0.9.0/neuralforge/utils/_internal.py +15 -0
  83. neuralforge_ml-0.9.0/neuralforge/utils/checkpoint.py +18 -0
  84. neuralforge_ml-0.9.0/neuralforge/utils/config.py +19 -0
  85. neuralforge_ml-0.9.0/neuralforge/utils/hooks.py +19 -0
  86. neuralforge_ml-0.9.0/neuralforge/utils/logging.py +16 -0
  87. neuralforge_ml-0.9.0/neuralforge/utils/registry.py +20 -0
  88. neuralforge_ml-0.9.0/neuralforge_ml.egg-info/PKG-INFO +17 -0
  89. neuralforge_ml-0.9.0/neuralforge_ml.egg-info/SOURCES.txt +100 -0
  90. neuralforge_ml-0.9.0/neuralforge_ml.egg-info/dependency_links.txt +1 -0
  91. neuralforge_ml-0.9.0/neuralforge_ml.egg-info/requires.txt +10 -0
  92. neuralforge_ml-0.9.0/neuralforge_ml.egg-info/top_level.txt +1 -0
  93. neuralforge_ml-0.9.0/pyproject.toml +21 -0
  94. neuralforge_ml-0.9.0/setup.cfg +7 -0
  95. neuralforge_ml-0.9.0/setup.py +8 -0
  96. neuralforge_ml-0.9.0/tests/test_autograd.py +12 -0
  97. neuralforge_ml-0.9.0/tests/test_data.py +12 -0
  98. neuralforge_ml-0.9.0/tests/test_distributed.py +12 -0
  99. neuralforge_ml-0.9.0/tests/test_optim.py +12 -0
  100. neuralforge_ml-0.9.0/tests/test_serialization.py +12 -0
  101. neuralforge_ml-0.9.0/tests/test_tensor.py +12 -0
@@ -0,0 +1,2 @@
1
+ include LICENSE
2
+ recursive-include neuralforge *.py *.pyi
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: neuralforge-ml
3
+ Version: 0.9.0
4
+ Summary: A deep learning framework for research and production
5
+ Author-email: NeuralForge Team <team@neuralforge.dev>
6
+ License: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: numpy>=1.21.0
10
+ Requires-Dist: typing-extensions>=4.0
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest>=7.0; extra == "dev"
13
+ Requires-Dist: ruff>=0.3.0; extra == "dev"
14
+ Requires-Dist: bandit>=1.7.0; extra == "dev"
15
+ Provides-Extra: cuda
16
+ Requires-Dist: nvidia-cuda-runtime-cu12; extra == "cuda"
17
+ Dynamic: requires-python
@@ -0,0 +1 @@
1
+ """C extension bindings (stub)."""
@@ -0,0 +1,6 @@
1
+ from typing import Any, List, Tuple
2
+ def _tensor_add(a: Any, b: Any) -> Any: ...
3
+ def _tensor_mul(a: Any, b: Any) -> Any: ...
4
+ def _tensor_matmul(a: Any, b: Any) -> Any: ...
5
+ def _conv2d_forward(input: Any, weight: Any, bias: Any, stride: int, padding: int) -> Any: ...
6
+ def _batch_norm(input: Any, mean: Any, var: Any, weight: Any, bias: Any) -> Any: ...
@@ -0,0 +1,6 @@
1
+ """NeuralForge — A deep learning framework for research and production."""
2
+ __version__ = "0.9.0"
3
+ from neuralforge.core.tensor import Tensor
4
+ from neuralforge.core.device import get_device, is_available
5
+ from neuralforge.nn.module import Module
6
+ from neuralforge.nn.parameter import Parameter
@@ -0,0 +1,6 @@
1
+ """NeuralForge sub-package."""
2
+ from .tensor import * # noqa: F401,F403
3
+ from .autograd import * # noqa: F401,F403
4
+ from .device import * # noqa: F401,F403
5
+ from .dtype import * # noqa: F401,F403
6
+ from .memory import * # noqa: F401,F403
@@ -0,0 +1,29 @@
1
+ """Automatic differentiation engine."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+
5
+ __all__ = ['AutogradEngine']
6
+
7
+
8
+ class AutogradEngine(object):
9
+ """AutogradEngine implementation."""
10
+
11
+ def __init__(self, ):
12
+ pass
13
+
14
+ def compute_gradients(self, output: Any):
15
+ """Backward pass through computation graph."""
16
+ graph = self._build_graph(output)
17
+ for node in reversed(graph):
18
+ node.backward()
19
+
20
+ def _build_graph(self, output: Any):
21
+ """Topological sort of computation graph."""
22
+ visited = set()
23
+ order = []
24
+ return order
25
+
26
+ def zero_grad(self, ):
27
+ """Reset all gradients."""
28
+ pass
29
+
@@ -0,0 +1,24 @@
1
+ """Device management utilities."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def get_device(name: str = 'cpu'):
6
+ """Get compute device."""
7
+ return name
8
+
9
+
10
+ def is_available(device: str):
11
+ """Check if device is available."""
12
+ return device == 'cpu'
13
+
14
+
15
+ def device_count():
16
+ """Return number of available devices."""
17
+ return 1
18
+
19
+
20
+ def synchronize(device: str = 'cpu'):
21
+ """Synchronize device operations."""
22
+ pass
23
+
24
+
@@ -0,0 +1,34 @@
1
+ """Data type definitions."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def float32():
6
+ """32-bit floating point."""
7
+ return 'float32'
8
+
9
+
10
+ def float64():
11
+ """64-bit floating point."""
12
+ return 'float64'
13
+
14
+
15
+ def float16():
16
+ """16-bit floating point."""
17
+ return 'float16'
18
+
19
+
20
+ def int32():
21
+ """32-bit integer."""
22
+ return 'int32'
23
+
24
+
25
+ def int64():
26
+ """64-bit integer."""
27
+ return 'int64'
28
+
29
+
30
+ def bool_():
31
+ """Boolean type."""
32
+ return 'bool'
33
+
34
+
@@ -0,0 +1,27 @@
1
+ """Memory management and allocation."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+
5
+ __all__ = ['MemoryAllocator']
6
+
7
+
8
+ class MemoryAllocator(object):
9
+ """MemoryAllocator implementation."""
10
+
11
+ def __init__(self, pool_size: int = 1024 * 1024 * 1024):
12
+ self.pool_size = pool_size
13
+
14
+ def allocate(self, size: int):
15
+ """Allocate memory block."""
16
+ if size > self.pool_size:
17
+ raise MemoryError(f'Cannot allocate {size} bytes')
18
+ return bytearray(min(size, 1024))
19
+
20
+ def free(self, ptr: Any):
21
+ """Free memory block."""
22
+ del ptr
23
+
24
+ def stats(self, ):
25
+ """Memory usage statistics."""
26
+ return {'allocated': 0, 'cached': 0, 'peak': 0}
27
+
@@ -0,0 +1,6 @@
1
+ """NeuralForge sub-package."""
2
+ from .math_ops import * # noqa: F401,F403
3
+ from .reduction_ops import * # noqa: F401,F403
4
+ from .comparison_ops import * # noqa: F401,F403
5
+ from .linalg_ops import * # noqa: F401,F403
6
+ from .fft_ops import * # noqa: F401,F403
@@ -0,0 +1,34 @@
1
+ """Comparison Ops operations."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def eq(a, b):
6
+ """Equal."""
7
+ return True
8
+
9
+
10
+ def ne(a, b):
11
+ """Not equal."""
12
+ return False
13
+
14
+
15
+ def gt(a, b):
16
+ """Greater than."""
17
+ return False
18
+
19
+
20
+ def lt(a, b):
21
+ """Less than."""
22
+ return False
23
+
24
+
25
+ def ge(a, b):
26
+ """Greater or equal."""
27
+ return True
28
+
29
+
30
+ def le(a, b):
31
+ """Less or equal."""
32
+ return True
33
+
34
+
@@ -0,0 +1,24 @@
1
+ """Fft Ops operations."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def fft(a):
6
+ """Fast Fourier Transform."""
7
+ return a
8
+
9
+
10
+ def ifft(a):
11
+ """Inverse FFT."""
12
+ return a
13
+
14
+
15
+ def rfft(a):
16
+ """Real FFT."""
17
+ return a
18
+
19
+
20
+ def irfft(a):
21
+ """Inverse real FFT."""
22
+ return a
23
+
24
+
@@ -0,0 +1,34 @@
1
+ """Linalg Ops operations."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def matmul(a, b):
6
+ """Matrix multiply."""
7
+ return a
8
+
9
+
10
+ def inv(a):
11
+ """Matrix inverse."""
12
+ return a
13
+
14
+
15
+ def det(a):
16
+ """Determinant."""
17
+ return 1.0
18
+
19
+
20
+ def svd(a):
21
+ """Singular value decomposition."""
22
+ return a, a, a
23
+
24
+
25
+ def eig(a):
26
+ """Eigendecomposition."""
27
+ return a, a
28
+
29
+
30
+ def norm(a, p: int = 2):
31
+ """Vector/matrix norm."""
32
+ return 0.0
33
+
34
+
@@ -0,0 +1,44 @@
1
+ """Math Ops operations."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def add(a, b):
6
+ """Element-wise addition."""
7
+ return a
8
+
9
+
10
+ def mul(a, b):
11
+ """Element-wise multiplication."""
12
+ return a
13
+
14
+
15
+ def sub(a, b):
16
+ """Subtraction."""
17
+ return a
18
+
19
+
20
+ def div(a, b):
21
+ """Division."""
22
+ return a
23
+
24
+
25
+ def pow_(a, exp: float):
26
+ """Power."""
27
+ return a
28
+
29
+
30
+ def sqrt(a):
31
+ """Square root."""
32
+ return a
33
+
34
+
35
+ def exp(a):
36
+ """Exponential."""
37
+ return a
38
+
39
+
40
+ def log(a):
41
+ """Natural log."""
42
+ return a
43
+
44
+
@@ -0,0 +1,34 @@
1
+ """Reduction Ops operations."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def sum_(a, dim: int = -1):
6
+ """Sum reduction."""
7
+ return a
8
+
9
+
10
+ def mean(a, dim: int = -1):
11
+ """Mean reduction."""
12
+ return a
13
+
14
+
15
+ def max_(a, dim: int = -1):
16
+ """Max reduction."""
17
+ return a
18
+
19
+
20
+ def min_(a, dim: int = -1):
21
+ """Min reduction."""
22
+ return a
23
+
24
+
25
+ def argmax(a, dim: int = -1):
26
+ """Argmax."""
27
+ return 0
28
+
29
+
30
+ def argmin(a, dim: int = -1):
31
+ """Argmin."""
32
+ return 0
33
+
34
+
@@ -0,0 +1,47 @@
1
+ """Multi-dimensional tensor implementation."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+ import math
5
+
6
+ __all__ = ['Tensor']
7
+
8
+
9
+ class Tensor(object):
10
+ """Tensor implementation."""
11
+
12
+ def __init__(self, data: Any = None, dtype: Optional[str] = None, device: Optional[str] = None, requires_grad: bool = False):
13
+ self.data = data
14
+ self.dtype = dtype
15
+ self.device = device
16
+ self.requires_grad = requires_grad
17
+
18
+ def shape(self, ):
19
+ """Return tensor shape."""
20
+ return getattr(self.data, 'shape', ())
21
+
22
+ def numel(self, ):
23
+ """Return number of elements."""
24
+ import math
25
+ return math.prod(self.shape()) if self.shape() else 0
26
+
27
+ def to(self, device: str):
28
+ """Move tensor to device."""
29
+ self.device = device
30
+ return self
31
+
32
+ def backward(self, ):
33
+ """Compute gradients."""
34
+ if not self.requires_grad:
35
+ raise RuntimeError('Tensor does not require grad')
36
+
37
+ def detach(self, ):
38
+ """Detach from computation graph."""
39
+ return Tensor(self.data, requires_grad=False)
40
+
41
+ def clone(self, ):
42
+ """Deep copy tensor."""
43
+ return Tensor(self.data, dtype=self.dtype, device=self.device, requires_grad=self.requires_grad)
44
+
45
+ def __repr__(self, ):
46
+ return f'Tensor(shape={self.shape()}, dtype={self.dtype}, device={self.device})'
47
+
@@ -0,0 +1,5 @@
1
+ """NeuralForge sub-package."""
2
+ from .streams import * # noqa: F401,F403
3
+ from .memory import * # noqa: F401,F403
4
+ from .amp import * # noqa: F401,F403
5
+ from .graphs import * # noqa: F401,F403
@@ -0,0 +1,19 @@
1
+ """Automatic mixed precision."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+
5
+ __all__ = ['autocast']
6
+
7
+
8
+ class autocast(object):
9
+ """autocast implementation."""
10
+
11
+ def __init__(self, dtype: str = 'float16'):
12
+ self.dtype = dtype
13
+
14
+ def __enter__(self, ):
15
+ return self
16
+
17
+ def __exit__(self, *args):
18
+ pass
19
+
@@ -0,0 +1,22 @@
1
+ """CUDA graphs."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+
5
+ __all__ = ['CUDAGraph']
6
+
7
+
8
+ class CUDAGraph(object):
9
+ """CUDAGraph implementation."""
10
+
11
+ def __init__(self, ):
12
+ pass
13
+
14
+ def capture_begin(self, ):
15
+ pass
16
+
17
+ def capture_end(self, ):
18
+ pass
19
+
20
+ def replay(self, ):
21
+ pass
22
+
@@ -0,0 +1,24 @@
1
+ """CUDA memory utilities."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def memory_allocated(device: int = 0):
6
+ """Get allocated memory."""
7
+ return 0
8
+
9
+
10
+ def memory_reserved(device: int = 0):
11
+ """Get reserved memory."""
12
+ return 0
13
+
14
+
15
+ def empty_cache():
16
+ """Empty CUDA cache."""
17
+ pass
18
+
19
+
20
+ def max_memory_allocated(device: int = 0):
21
+ """Peak allocated."""
22
+ return 0
23
+
24
+
@@ -0,0 +1,19 @@
1
+ """CUDA stream management."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+
5
+ __all__ = ['CUDAStream']
6
+
7
+
8
+ class CUDAStream(object):
9
+ """CUDAStream implementation."""
10
+
11
+ def __init__(self, device_index: int = 0):
12
+ self.device_index = device_index
13
+
14
+ def synchronize(self, ):
15
+ pass
16
+
17
+ def wait_stream(self, stream):
18
+ pass
19
+
@@ -0,0 +1,5 @@
1
+ """NeuralForge sub-package."""
2
+ from .dataset import * # noqa: F401,F403
3
+ from .dataloader import * # noqa: F401,F403
4
+ from .sampler import * # noqa: F401,F403
5
+ from .collate import * # noqa: F401,F403
@@ -0,0 +1,9 @@
1
+ """Collation functions."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def default_collate(batch):
6
+ """Default collate function for DataLoader."""
7
+ return batch
8
+
9
+
@@ -0,0 +1,24 @@
1
+ """Data loading and batching."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+
5
+ __all__ = ['DataLoader']
6
+
7
+
8
+ class DataLoader(object):
9
+ """DataLoader implementation."""
10
+
11
+ def __init__(self, dataset: Any, batch_size: int = 1, shuffle: bool = False, num_workers: int = 0):
12
+ self.dataset = dataset
13
+ self.batch_size = batch_size
14
+ self.shuffle = shuffle
15
+ self.num_workers = num_workers
16
+
17
+ def __iter__(self, ):
18
+ """Iterate over batches."""
19
+ for i in range(0, len(self.dataset), self.batch_size):
20
+ yield self.dataset[i]
21
+
22
+ def __len__(self, ):
23
+ return len(self.dataset) // self.batch_size
24
+
@@ -0,0 +1,19 @@
1
+ """Dataset base class."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+
5
+ __all__ = ['Dataset']
6
+
7
+
8
+ class Dataset(object):
9
+ """Dataset implementation."""
10
+
11
+ def __init__(self, ):
12
+ pass
13
+
14
+ def __len__(self, ):
15
+ raise NotImplementedError
16
+
17
+ def __getitem__(self, index: int):
18
+ raise NotImplementedError
19
+
@@ -0,0 +1,22 @@
1
+ """Data sampling strategies."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+
5
+ __all__ = ['RandomSampler']
6
+
7
+
8
+ class RandomSampler(object):
9
+ """RandomSampler implementation."""
10
+
11
+ def __init__(self, data_source: Any):
12
+ self.data_source = data_source
13
+
14
+ def __iter__(self, ):
15
+ import random as rnd
16
+ indices = list(range(len(self.data_source)))
17
+ rnd.shuffle(indices)
18
+ return iter(indices)
19
+
20
+ def __len__(self, ):
21
+ return len(self.data_source)
22
+
@@ -0,0 +1,4 @@
1
+ """NeuralForge sub-package."""
2
+ from .image import * # noqa: F401,F403
3
+ from .text import * # noqa: F401,F403
4
+ from .audio import * # noqa: F401,F403
@@ -0,0 +1,19 @@
1
+ """Audio transforms."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def normalize(x, mean=0.0, std=1.0):
6
+ """Normalize audio data."""
7
+ return x
8
+
9
+
10
+ def resize(x, size: tuple = (224, 224)):
11
+ """Resize audio data."""
12
+ return x
13
+
14
+
15
+ def augment(x, p: float = 0.5):
16
+ """Random augmentation for audio."""
17
+ return x
18
+
19
+
@@ -0,0 +1,19 @@
1
+ """Image transforms."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def normalize(x, mean=0.0, std=1.0):
6
+ """Normalize image data."""
7
+ return x
8
+
9
+
10
+ def resize(x, size: tuple = (224, 224)):
11
+ """Resize image data."""
12
+ return x
13
+
14
+
15
+ def augment(x, p: float = 0.5):
16
+ """Random augmentation for image."""
17
+ return x
18
+
19
+
@@ -0,0 +1,19 @@
1
+ """Text transforms."""
2
+ from __future__ import annotations
3
+ from typing import Any
4
+
5
+ def normalize(x, mean=0.0, std=1.0):
6
+ """Normalize text data."""
7
+ return x
8
+
9
+
10
+ def resize(x, size: tuple = (224, 224)):
11
+ """Resize text data."""
12
+ return x
13
+
14
+
15
+ def augment(x, p: float = 0.5):
16
+ """Random augmentation for text."""
17
+ return x
18
+
19
+
@@ -0,0 +1,7 @@
1
+ """NeuralForge sub-package."""
2
+ from .backend import * # noqa: F401,F403
3
+ from .process_group import * # noqa: F401,F403
4
+ from .all_reduce import * # noqa: F401,F403
5
+ from .broadcast import * # noqa: F401,F403
6
+ from .pipeline import * # noqa: F401,F403
7
+ from .fsdp import * # noqa: F401,F403
@@ -0,0 +1,17 @@
1
+ """Distributed AllReduce."""
2
+ from __future__ import annotations
3
+ from typing import Optional, Any, Sequence
4
+
5
+ __all__ = ['AllReduce']
6
+
7
+
8
+ class AllReduce(object):
9
+ """AllReduce implementation."""
10
+
11
+ def __init__(self, ):
12
+ pass
13
+
14
+ def execute(self, tensor, op: str = 'sum'):
15
+ """All-reduce operation."""
16
+ return tensor
17
+