DepthTensor 2.5.0__tar.gz → 2.5.1__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.
- {depthtensor-2.5.0 → depthtensor-2.5.1}/PKG-INFO +1 -1
- {depthtensor-2.5.0 → depthtensor-2.5.1}/pyproject.toml +1 -1
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/__init__.py +1 -1
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/ops/elementwise.py +16 -16
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/depthtensor.egg-info/PKG-INFO +1 -1
- {depthtensor-2.5.0 → depthtensor-2.5.1}/LICENSE +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/README.md +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/setup.cfg +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/__init__.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/exceptions.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/ops/__init__.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/ops/comparison.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/ops/creation.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/ops/function.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/ops/reduction.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/random/__init__.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/random/generator.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/_core/utils.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/autodiff.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/tensor.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/DepthTensor/typing.py +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/depthtensor.egg-info/SOURCES.txt +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/depthtensor.egg-info/dependency_links.txt +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/depthtensor.egg-info/requires.txt +0 -0
- {depthtensor-2.5.0 → depthtensor-2.5.1}/src/depthtensor.egg-info/top_level.txt +0 -0
|
@@ -45,17 +45,11 @@ def get_requires_grad_and_prev(x1: TensorLike, x2: TensorLike):
|
|
|
45
45
|
from ...tensor import Tensor
|
|
46
46
|
|
|
47
47
|
y_requires_grad = False
|
|
48
|
-
prev = ()
|
|
49
48
|
if isinstance(x1, Tensor):
|
|
50
49
|
y_requires_grad = x1.requires_grad
|
|
51
|
-
prev = (x1,)
|
|
52
50
|
if isinstance(x2, Tensor):
|
|
53
51
|
y_requires_grad = y_requires_grad or x2.requires_grad
|
|
54
|
-
|
|
55
|
-
prev = (x1, x2)
|
|
56
|
-
else:
|
|
57
|
-
prev = (x2,)
|
|
58
|
-
return y_requires_grad, prev
|
|
52
|
+
return y_requires_grad
|
|
59
53
|
|
|
60
54
|
|
|
61
55
|
def wrapper_2in_1out(
|
|
@@ -104,8 +98,8 @@ def wrapper_2in_1out(
|
|
|
104
98
|
x1.data = y
|
|
105
99
|
return x1
|
|
106
100
|
|
|
107
|
-
requires_grad
|
|
108
|
-
return Tensor(y,
|
|
101
|
+
requires_grad = get_requires_grad_and_prev(x1, x2)
|
|
102
|
+
return Tensor(y, requires_grad=requires_grad)
|
|
109
103
|
|
|
110
104
|
|
|
111
105
|
def wrapper_1in_1out(
|
|
@@ -176,23 +170,25 @@ def wrapper_diff_2in_1out(
|
|
|
176
170
|
x2, device=device
|
|
177
171
|
)
|
|
178
172
|
|
|
179
|
-
prev = []
|
|
180
173
|
if isinstance(x1, Tensor) and x1.requires_grad:
|
|
181
174
|
if x1.grad is None:
|
|
182
175
|
x1.zero_grad()
|
|
183
176
|
x1.grad += callback_x1(y_grad, x1.shape, device, x1_data, x2_data).astype(
|
|
184
177
|
x1.dtype
|
|
185
178
|
)
|
|
186
|
-
prev.append(x1)
|
|
187
179
|
if isinstance(x2, Tensor) and x2.requires_grad:
|
|
188
180
|
if x2.grad is None:
|
|
189
181
|
x2.zero_grad()
|
|
190
182
|
x2.grad += callback_x2(y_grad, x2.shape, device, x1_data, x2_data).astype(
|
|
191
183
|
x2.dtype
|
|
192
184
|
)
|
|
193
|
-
prev.append(x2)
|
|
194
|
-
y.prev = tuple(prev)
|
|
195
185
|
|
|
186
|
+
prev = []
|
|
187
|
+
if isinstance(x1, Tensor) and x1.requires_grad:
|
|
188
|
+
prev.append(x1)
|
|
189
|
+
if isinstance(x2, Tensor) and x2.requires_grad:
|
|
190
|
+
prev.append(x2)
|
|
191
|
+
y.prev = tuple(prev)
|
|
196
192
|
y.backward = backward
|
|
197
193
|
|
|
198
194
|
|
|
@@ -212,8 +208,9 @@ def wrapper_diff_1in_1out(y: TensorType, x1: TensorLike, callback_x1: Callable)
|
|
|
212
208
|
if x1.grad is None:
|
|
213
209
|
x1.zero_grad()
|
|
214
210
|
x1.grad += callback_x1(result_grad, x1.shape, x1.device, _x)
|
|
215
|
-
y.prev = (x1,)
|
|
216
211
|
|
|
212
|
+
if isinstance(x1, Tensor) and x1.requires_grad:
|
|
213
|
+
y.prev = (x1,)
|
|
217
214
|
y.backward = backward
|
|
218
215
|
|
|
219
216
|
|
|
@@ -882,9 +879,12 @@ class mean_cls(Function):
|
|
|
882
879
|
y.zero_grad()
|
|
883
880
|
if x.grad is None:
|
|
884
881
|
x.zero_grad()
|
|
885
|
-
print(x)
|
|
886
882
|
x.grad += callback_x1(y.grad, x.shape, y.device)
|
|
887
883
|
|
|
884
|
+
from ...tensor import Tensor
|
|
885
|
+
|
|
886
|
+
if isinstance(x, Tensor) and x.requires_grad:
|
|
887
|
+
y.prev = (x,)
|
|
888
888
|
y.backward = backward
|
|
889
889
|
|
|
890
890
|
def __call__(
|
|
@@ -929,7 +929,7 @@ class mean_cls(Function):
|
|
|
929
929
|
return x
|
|
930
930
|
requires_grad = x.requires_grad
|
|
931
931
|
|
|
932
|
-
y = Tensor(y,
|
|
932
|
+
y = Tensor(y, requires_grad=requires_grad)
|
|
933
933
|
if differentiate:
|
|
934
934
|
self.link(y, x, axis, keepdims)
|
|
935
935
|
else:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|