depthtensor 2.4.2__tar.gz → 2.4.3__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 (25) hide show
  1. {depthtensor-2.4.2 → depthtensor-2.4.3}/PKG-INFO +1 -1
  2. {depthtensor-2.4.2 → depthtensor-2.4.3}/pyproject.toml +1 -1
  3. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/__init__.py +1 -1
  4. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/ops/elementwise.py +2 -2
  5. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/ops/reduction.py +6 -3
  6. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/autodiff.py +7 -0
  7. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/typing.py +7 -2
  8. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/depthtensor.egg-info/PKG-INFO +1 -1
  9. {depthtensor-2.4.2 → depthtensor-2.4.3}/LICENSE +0 -0
  10. {depthtensor-2.4.2 → depthtensor-2.4.3}/README.md +0 -0
  11. {depthtensor-2.4.2 → depthtensor-2.4.3}/setup.cfg +0 -0
  12. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/__init__.py +0 -0
  13. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/exceptions.py +0 -0
  14. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/ops/__init__.py +0 -0
  15. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/ops/comparison.py +0 -0
  16. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/ops/creation.py +0 -0
  17. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/ops/diff.py +0 -0
  18. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/random/__init__.py +0 -0
  19. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/random/generator.py +0 -0
  20. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/_core/utils.py +0 -0
  21. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/DepthTensor/tensor.py +0 -0
  22. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/depthtensor.egg-info/SOURCES.txt +0 -0
  23. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/depthtensor.egg-info/dependency_links.txt +0 -0
  24. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/depthtensor.egg-info/requires.txt +0 -0
  25. {depthtensor-2.4.2 → depthtensor-2.4.3}/src/depthtensor.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: depthtensor
3
- Version: 2.4.2
3
+ Version: 2.4.3
4
4
  Summary: A Hardware-Accelerated Tensor Computation and Autograd Engine
5
5
  Author-email: Le Hong Ha <lehahong1310@gmail.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "depthtensor"
7
- version = "2.4.2"
7
+ version = "2.4.3"
8
8
  description = "A Hardware-Accelerated Tensor Computation and Autograd Engine"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -6,4 +6,4 @@ from ._core.ops import *
6
6
  from ._core.exceptions import *
7
7
  from ._core import random
8
8
 
9
- __version__ = "2.4.2"
9
+ __version__ = "2.4.3"
@@ -105,7 +105,7 @@ def create_2in_1out(op: BinaryOp, diff: BinaryDiff | None) -> BinaryFunc:
105
105
  if y.requires_grad:
106
106
  if y.grad is None:
107
107
  y.zeros_grad()
108
- dx1, dx2 = diff(y, a1, a2, **kwds)
108
+ dx1, dx2 = diff(y, a1, a2, device=op_device, **kwds)
109
109
 
110
110
  def backward() -> None:
111
111
  if isinstance(x1, Tensor) and x1.requires_grad:
@@ -171,7 +171,7 @@ def create_1in_1out(op: UnaryOp, diff: UnaryDiff | None) -> UnaryFunc:
171
171
  if y.requires_grad:
172
172
  if y.grad is None:
173
173
  y.zeros_grad()
174
- dx = diff(y, a, **kwds)
174
+ dx = diff(y, a, device=device_op, **kwds)
175
175
 
176
176
  def backward() -> None:
177
177
  if isinstance(x, Tensor) and x.requires_grad:
@@ -90,9 +90,12 @@ def max(
90
90
 
91
91
  arr = to_tensordata(a, device=device_op)
92
92
  if device_op == "cpu":
93
- y = np.max(
94
- arr, axis=axis, out=out, keepdims=keepdims, initial=initial, where=where
95
- )
93
+ kwargs = {"axis": axis, "out": out, "keepdims": keepdims, "where": where}
94
+
95
+ if initial is not _NoValue:
96
+ kwargs["initial"] = initial
97
+
98
+ y = np.max(arr, **kwargs)
96
99
  else:
97
100
  if cp is None:
98
101
  raise CuPyNotFound(CUPY_NOT_FOUND_MSG)
@@ -59,6 +59,13 @@ def differentiate(tensor: Tensor, grad: TensorData | None = None) -> list[Tensor
59
59
  if grad is not None:
60
60
  _grad_check(grad, tensor)
61
61
  tensor.grad += grad
62
+ else:
63
+ if tensor.device == "gpu":
64
+ if cp is None:
65
+ raise CuPyNotFound(CUPY_NOT_FOUND_MSG)
66
+ tensor.grad = cp.ones(tensor.shape, tensor.dtype)
67
+ elif tensor.device == "cpu":
68
+ tensor.grad = np.ones(tensor.shape, tensor.dtype)
62
69
 
63
70
  for t in reversed(topo):
64
71
  if t.backward is None:
@@ -65,7 +65,12 @@ class BinaryOp(Protocol):
65
65
 
66
66
  class BinaryDiff(Protocol):
67
67
  def __call__(
68
- self, result: "Tensor", x1: TensorData, x2: TensorData, **kwds: Any
68
+ self,
69
+ result: "Tensor",
70
+ x1: TensorData,
71
+ x2: TensorData,
72
+ device: Device,
73
+ **kwds: Any,
69
74
  ) -> tuple[Callable[[], TensorData], Callable[[], TensorData]]: ...
70
75
 
71
76
 
@@ -91,5 +96,5 @@ class UnaryOp(Protocol):
91
96
 
92
97
  class UnaryDiff(Protocol):
93
98
  def __call__(
94
- self, result: "Tensor", x: TensorData, **kwds: Any
99
+ self, result: "Tensor", x: TensorData, device: Device, **kwds: Any
95
100
  ) -> Callable[[], TensorData]: ...
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: depthtensor
3
- Version: 2.4.2
3
+ Version: 2.4.3
4
4
  Summary: A Hardware-Accelerated Tensor Computation and Autograd Engine
5
5
  Author-email: Le Hong Ha <lehahong1310@gmail.com>
6
6
  License: MIT License
File without changes
File without changes
File without changes