DepthTensor 2.2.1__py3-none-any.whl → 2.3.0__py3-none-any.whl
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/__init__.py +1 -1
- DepthTensor/_core/ops/diff.py +87 -47
- DepthTensor/_core/ops/elementwise.py +51 -1
- DepthTensor/_core/utils.py +1 -1
- DepthTensor/tensor.py +40 -8
- {depthtensor-2.2.1.dist-info → depthtensor-2.3.0.dist-info}/METADATA +1 -1
- {depthtensor-2.2.1.dist-info → depthtensor-2.3.0.dist-info}/RECORD +10 -10
- {depthtensor-2.2.1.dist-info → depthtensor-2.3.0.dist-info}/WHEEL +0 -0
- {depthtensor-2.2.1.dist-info → depthtensor-2.3.0.dist-info}/licenses/LICENSE +0 -0
- {depthtensor-2.2.1.dist-info → depthtensor-2.3.0.dist-info}/top_level.txt +0 -0
DepthTensor/__init__.py
CHANGED
DepthTensor/_core/ops/diff.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
from typing import Callable
|
|
2
2
|
|
|
3
|
-
from ...typing import OperandLike, TensorLike, NDArrayLike
|
|
3
|
+
from ...typing import OperandLike, TensorLike, NDArrayLike, AxisLike
|
|
4
4
|
|
|
5
5
|
from ..utils import sum_to_shape, to_xp_array, get_two_operand_op_device
|
|
6
6
|
from ..exceptions import CuPyNotFound, CUPY_NOT_FOUND_MSG
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
|
+
import math
|
|
9
10
|
|
|
10
11
|
try:
|
|
11
12
|
import cupy as cp
|
|
@@ -34,20 +35,22 @@ def wrapper_2in_diff(
|
|
|
34
35
|
|
|
35
36
|
result_grad: NDArrayLike = result.grad
|
|
36
37
|
device = get_two_operand_op_device(x1, x2, None)
|
|
37
|
-
|
|
38
|
+
x1_data, x2_data = to_xp_array(x1, device=device), to_xp_array(
|
|
39
|
+
x2, device=device
|
|
40
|
+
)
|
|
38
41
|
|
|
39
42
|
if isinstance(x1, Tensor) and x1.requires_grad:
|
|
40
43
|
if x1.grad is None:
|
|
41
44
|
x1.zeros_grad()
|
|
42
|
-
x1.grad += callback_x1(
|
|
43
|
-
x1.
|
|
44
|
-
)
|
|
45
|
+
x1.grad += callback_x1(
|
|
46
|
+
result_grad, x1.shape, device, x1_data, x2_data
|
|
47
|
+
).astype(x1.dtype)
|
|
45
48
|
if isinstance(x2, Tensor) and x2.requires_grad:
|
|
46
49
|
if x2.grad is None:
|
|
47
50
|
x2.zeros_grad()
|
|
48
|
-
x2.grad += callback_x2(
|
|
49
|
-
x2.
|
|
50
|
-
)
|
|
51
|
+
x2.grad += callback_x2(
|
|
52
|
+
result_grad, x2.shape, device, x1_data, x2_data
|
|
53
|
+
).astype(x2.dtype)
|
|
51
54
|
|
|
52
55
|
result.backward = backward
|
|
53
56
|
return result
|
|
@@ -81,95 +84,101 @@ def wrapper_1in_diff(
|
|
|
81
84
|
|
|
82
85
|
|
|
83
86
|
def add_diff(result: TensorLike, x1: OperandLike, x2: OperandLike) -> TensorLike:
|
|
84
|
-
def callback_x1(result_grad,
|
|
85
|
-
return sum_to_shape(result_grad,
|
|
87
|
+
def callback_x1(result_grad, x1_shape, device, x1_data, x2_data):
|
|
88
|
+
return sum_to_shape(result_grad, x1_shape, device)
|
|
86
89
|
|
|
87
|
-
def callback_x2(result_grad,
|
|
88
|
-
return sum_to_shape(result_grad,
|
|
90
|
+
def callback_x2(result_grad, x2_shape, device, x1_data, x2_data):
|
|
91
|
+
return sum_to_shape(result_grad, x2_shape, device)
|
|
89
92
|
|
|
90
93
|
return wrapper_2in_diff(result, x1, x2, callback_x1, callback_x2)
|
|
91
94
|
|
|
92
95
|
|
|
93
96
|
def subtract_diff(result: TensorLike, x1: OperandLike, x2: OperandLike) -> TensorLike:
|
|
94
97
|
|
|
95
|
-
def callback_x1(result_grad,
|
|
96
|
-
return sum_to_shape(result_grad,
|
|
98
|
+
def callback_x1(result_grad, x1_shape, device, x1_data, x2_data):
|
|
99
|
+
return sum_to_shape(result_grad, x1_shape, device)
|
|
97
100
|
|
|
98
|
-
def callback_x2(result_grad,
|
|
99
|
-
return sum_to_shape(-result_grad,
|
|
101
|
+
def callback_x2(result_grad, x2_shape, device, x1_data, x2_data):
|
|
102
|
+
return sum_to_shape(-result_grad, x2_shape, device)
|
|
100
103
|
|
|
101
104
|
return wrapper_2in_diff(result, x1, x2, callback_x1, callback_x2)
|
|
102
105
|
|
|
103
106
|
|
|
104
107
|
def multiply_diff(result: TensorLike, x1: OperandLike, x2: OperandLike) -> TensorLike:
|
|
105
108
|
|
|
106
|
-
def callback_x1(result_grad,
|
|
107
|
-
return sum_to_shape(result_grad *
|
|
109
|
+
def callback_x1(result_grad, x1_shape, device, x1_data, x2_data):
|
|
110
|
+
return sum_to_shape(result_grad * x2_data, x1_shape, device)
|
|
108
111
|
|
|
109
|
-
def callback_x2(result_grad,
|
|
110
|
-
return sum_to_shape(result_grad *
|
|
112
|
+
def callback_x2(result_grad, x2_shape, device, x1_data, x2_data):
|
|
113
|
+
return sum_to_shape(result_grad * x1_data, x2_shape, device)
|
|
111
114
|
|
|
112
115
|
return wrapper_2in_diff(result, x1, x2, callback_x1, callback_x2)
|
|
113
116
|
|
|
114
117
|
|
|
115
118
|
def matmul_diff(result: TensorLike, x1: OperandLike, x2: OperandLike) -> TensorLike:
|
|
116
119
|
|
|
117
|
-
def callback_x1(result_grad,
|
|
118
|
-
return sum_to_shape(result_grad @
|
|
120
|
+
def callback_x1(result_grad, x1_shape, device, x1_data, x2_data):
|
|
121
|
+
return sum_to_shape(result_grad @ x2_data.swapaxes(-2, -1), x1_shape, device)
|
|
119
122
|
|
|
120
|
-
def callback_x2(result_grad,
|
|
121
|
-
return sum_to_shape(
|
|
123
|
+
def callback_x2(result_grad, x2_shape, device, x1_data, x2_data):
|
|
124
|
+
return sum_to_shape(x1_data.swapaxes(-2, -1) @ result_grad, x2_shape, device)
|
|
122
125
|
|
|
123
126
|
return wrapper_2in_diff(result, x1, x2, callback_x1, callback_x2)
|
|
124
127
|
|
|
125
128
|
|
|
126
129
|
def divide_diff(result: TensorLike, x1: OperandLike, x2: OperandLike) -> TensorLike:
|
|
127
130
|
|
|
128
|
-
def callback_x1(result_grad,
|
|
129
|
-
return sum_to_shape(result_grad /
|
|
131
|
+
def callback_x1(result_grad, x1_shape, device, x1_data, x2_data):
|
|
132
|
+
return sum_to_shape(result_grad / x2_data, x1_shape, device)
|
|
130
133
|
|
|
131
|
-
def callback_x2(result_grad,
|
|
132
|
-
return sum_to_shape(result_grad * (
|
|
134
|
+
def callback_x2(result_grad, x2_shape, device, x1_data, x2_data):
|
|
135
|
+
return sum_to_shape(result_grad * (x1_data * -(x2_data**-2)), x2_shape, device)
|
|
133
136
|
|
|
134
137
|
return wrapper_2in_diff(result, x1, x2, callback_x1, callback_x2)
|
|
135
138
|
|
|
136
139
|
|
|
137
140
|
def power_diff(result: TensorLike, x1: OperandLike, x2: OperandLike) -> TensorLike:
|
|
138
141
|
|
|
139
|
-
def callback_x1(result_grad,
|
|
140
|
-
return sum_to_shape(
|
|
142
|
+
def callback_x1(result_grad, x1_shape, device, x1_data, x2_data):
|
|
143
|
+
return sum_to_shape(
|
|
144
|
+
result_grad * x2_data * x1_data ** (x2_data - 1), x1_shape, device
|
|
145
|
+
)
|
|
141
146
|
|
|
142
|
-
def callback_x2(result_grad,
|
|
147
|
+
def callback_x2(result_grad, x2_shape, device, x1_data, x2_data):
|
|
143
148
|
if device == "cpu":
|
|
144
|
-
return sum_to_shape(
|
|
149
|
+
return sum_to_shape(
|
|
150
|
+
result_grad * np.log(x1_data) * x1_data**x2_data, x2_shape, device
|
|
151
|
+
)
|
|
145
152
|
else:
|
|
146
153
|
if cp is None:
|
|
147
154
|
raise CuPyNotFound(CUPY_NOT_FOUND_MSG)
|
|
148
|
-
return sum_to_shape(
|
|
155
|
+
return sum_to_shape(
|
|
156
|
+
result_grad * cp.log(x1_data) * x1_data**x2_data, x2_shape, device
|
|
157
|
+
)
|
|
149
158
|
|
|
150
159
|
return wrapper_2in_diff(result, x1, x2, callback_x1, callback_x2)
|
|
151
160
|
|
|
152
161
|
|
|
153
162
|
def negative_diff(result: TensorLike, x: TensorLike) -> TensorLike:
|
|
154
163
|
|
|
155
|
-
def callback_x1(result_grad,
|
|
156
|
-
return sum_to_shape(-result_grad,
|
|
164
|
+
def callback_x1(result_grad, x1_shape, device, x1_data):
|
|
165
|
+
return sum_to_shape(-result_grad, x1_shape, device)
|
|
157
166
|
|
|
158
167
|
return wrapper_1in_diff(result, x, callback_x1)
|
|
159
168
|
|
|
160
169
|
|
|
161
170
|
def sign_diff(result: TensorLike, x: TensorLike) -> TensorLike:
|
|
162
171
|
|
|
163
|
-
def callback_x1(result_grad,
|
|
164
|
-
return sum_to_shape(result_grad * 0,
|
|
172
|
+
def callback_x1(result_grad, x1_shape, device, x1_data):
|
|
173
|
+
return sum_to_shape(result_grad * 0, x1_shape, device)
|
|
165
174
|
|
|
166
175
|
return wrapper_1in_diff(result, x, callback_x1)
|
|
167
176
|
|
|
168
177
|
|
|
169
178
|
def abs_diff(result: TensorLike, x: TensorLike) -> TensorLike:
|
|
170
179
|
|
|
171
|
-
def callback_x1(result_grad,
|
|
172
|
-
return sum_to_shape(result_grad * result.data /
|
|
180
|
+
def callback_x1(result_grad, x1_shape, device, x1_data):
|
|
181
|
+
return sum_to_shape(result_grad * result.data / x1_data, x1_shape, device)
|
|
173
182
|
|
|
174
183
|
return wrapper_1in_diff(result, x, callback_x1)
|
|
175
184
|
|
|
@@ -181,32 +190,62 @@ def abs_diff(result: TensorLike, x: TensorLike) -> TensorLike:
|
|
|
181
190
|
|
|
182
191
|
def exp_diff(result: TensorLike, x: TensorLike) -> TensorLike:
|
|
183
192
|
|
|
184
|
-
def callback_x1(result_grad,
|
|
185
|
-
return sum_to_shape(result_grad * result.data,
|
|
193
|
+
def callback_x1(result_grad, x1_shape, device, x1_data):
|
|
194
|
+
return sum_to_shape(result_grad * result.data, x1_shape, device)
|
|
186
195
|
|
|
187
196
|
return wrapper_1in_diff(result, x, callback_x1)
|
|
188
197
|
|
|
189
198
|
|
|
190
199
|
def sqrt_diff(result: TensorLike, x: TensorLike) -> TensorLike:
|
|
191
200
|
|
|
192
|
-
def callback_x1(result_grad,
|
|
193
|
-
return sum_to_shape(
|
|
201
|
+
def callback_x1(result_grad, x1_shape, device, x1_data):
|
|
202
|
+
return sum_to_shape(
|
|
203
|
+
result_grad * (0.5 * result.data ** (-0.5)), x1_shape, device
|
|
204
|
+
)
|
|
194
205
|
|
|
195
206
|
return wrapper_1in_diff(result, x, callback_x1)
|
|
196
207
|
|
|
197
208
|
|
|
198
209
|
def log_diff(result: TensorLike, x: TensorLike) -> TensorLike:
|
|
199
210
|
|
|
200
|
-
def callback_x1(result_grad,
|
|
201
|
-
return sum_to_shape(result_grad /
|
|
211
|
+
def callback_x1(result_grad, x1_shape, device, x1_data):
|
|
212
|
+
return sum_to_shape(result_grad / x1_data, x1_shape, device)
|
|
202
213
|
|
|
203
214
|
return wrapper_1in_diff(result, x, callback_x1)
|
|
204
215
|
|
|
205
216
|
|
|
206
217
|
def square_diff(result: TensorLike, x: TensorLike) -> TensorLike:
|
|
207
218
|
|
|
208
|
-
def callback_x1(result_grad,
|
|
209
|
-
return sum_to_shape(result_grad * 2 *
|
|
219
|
+
def callback_x1(result_grad, x1_shape, device, x1_data):
|
|
220
|
+
return sum_to_shape(result_grad * 2 * x1_data, x1_shape, device)
|
|
221
|
+
|
|
222
|
+
return wrapper_1in_diff(result, x, callback_x1)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
###
|
|
226
|
+
###
|
|
227
|
+
###
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def mean_diff(
|
|
231
|
+
result: TensorLike, x: TensorLike, axis: AxisLike, keepdims: bool
|
|
232
|
+
) -> TensorLike:
|
|
233
|
+
def callback_x1(result_grad, x1_shape, device, _x):
|
|
234
|
+
if device == "cpu":
|
|
235
|
+
xp = np
|
|
236
|
+
else:
|
|
237
|
+
if cp is None:
|
|
238
|
+
raise CuPyNotFound(CUPY_NOT_FOUND_MSG)
|
|
239
|
+
xp = cp
|
|
240
|
+
|
|
241
|
+
inp_size = math.prod(x1_shape)
|
|
242
|
+
grad_size = result_grad.size
|
|
243
|
+
N = inp_size / grad_size
|
|
244
|
+
grad = result_grad * (1.0 / N)
|
|
245
|
+
|
|
246
|
+
if not keepdims and axis is not None:
|
|
247
|
+
grad = xp.expand_dims(grad, axis)
|
|
248
|
+
return xp.broadcast_to(grad, x1_shape)
|
|
210
249
|
|
|
211
250
|
return wrapper_1in_diff(result, x, callback_x1)
|
|
212
251
|
|
|
@@ -229,4 +268,5 @@ __all__ = [
|
|
|
229
268
|
"sqrt_diff",
|
|
230
269
|
"log_diff",
|
|
231
270
|
"square_diff",
|
|
271
|
+
"mean_diff",
|
|
232
272
|
]
|
|
@@ -5,6 +5,7 @@ from ...typing import (
|
|
|
5
5
|
DTypeLike,
|
|
6
6
|
Casting,
|
|
7
7
|
Order,
|
|
8
|
+
AxisLike,
|
|
8
9
|
NDArrayLikeBool,
|
|
9
10
|
NDArrayLike,
|
|
10
11
|
OperandLike,
|
|
@@ -243,7 +244,7 @@ def wrapper_1in_1out(
|
|
|
243
244
|
from ...tensor import Tensor
|
|
244
245
|
|
|
245
246
|
if device is None:
|
|
246
|
-
device_op = get_device(
|
|
247
|
+
device_op = get_device(x)
|
|
247
248
|
else:
|
|
248
249
|
device_op = device
|
|
249
250
|
|
|
@@ -711,6 +712,54 @@ def square(
|
|
|
711
712
|
)
|
|
712
713
|
|
|
713
714
|
|
|
715
|
+
###
|
|
716
|
+
###
|
|
717
|
+
###
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
def mean(
|
|
721
|
+
x: OperandLike,
|
|
722
|
+
/,
|
|
723
|
+
axis: Optional[AxisLike] = None,
|
|
724
|
+
dtype: Optional[DTypeLike] = None,
|
|
725
|
+
out: Optional[NDArrayLike] = None,
|
|
726
|
+
keepdims: bool = False,
|
|
727
|
+
*,
|
|
728
|
+
device: Optional[DeviceLike] = None,
|
|
729
|
+
in_place: bool = False,
|
|
730
|
+
where: Union[bool, NDArrayLikeBool] = True,
|
|
731
|
+
) -> TensorLike:
|
|
732
|
+
from ...tensor import Tensor
|
|
733
|
+
|
|
734
|
+
if device is None:
|
|
735
|
+
device_op = get_device(x)
|
|
736
|
+
else:
|
|
737
|
+
device_op = device
|
|
738
|
+
|
|
739
|
+
a = to_xp_array(x, device=device_op)
|
|
740
|
+
if device_op == "cpu":
|
|
741
|
+
y = np.mean(
|
|
742
|
+
a,
|
|
743
|
+
out=out,
|
|
744
|
+
dtype=dtype,
|
|
745
|
+
where=where,
|
|
746
|
+
axis=axis,
|
|
747
|
+
keepdims=keepdims,
|
|
748
|
+
)
|
|
749
|
+
else:
|
|
750
|
+
if cp is None:
|
|
751
|
+
raise CuPyNotFound(CUPY_NOT_FOUND_MSG)
|
|
752
|
+
y = cp.mean(a, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
|
|
753
|
+
|
|
754
|
+
requires_grad = False
|
|
755
|
+
if isinstance(x, Tensor):
|
|
756
|
+
if in_place:
|
|
757
|
+
x.data = y
|
|
758
|
+
return x
|
|
759
|
+
requires_grad = x.requires_grad
|
|
760
|
+
return Tensor(y, prev=(x,), requires_grad=requires_grad)
|
|
761
|
+
|
|
762
|
+
|
|
714
763
|
###
|
|
715
764
|
###
|
|
716
765
|
###
|
|
@@ -729,6 +778,7 @@ __all__ = [
|
|
|
729
778
|
"sqrt",
|
|
730
779
|
"log",
|
|
731
780
|
"square",
|
|
781
|
+
"mean",
|
|
732
782
|
"clip",
|
|
733
783
|
"create_2in_1out",
|
|
734
784
|
"create_1in_1out",
|
DepthTensor/_core/utils.py
CHANGED
|
@@ -151,7 +151,7 @@ def get_device(a: OperandLike) -> DeviceLike:
|
|
|
151
151
|
elif isinstance(a, (int, float, list, tuple, bool)):
|
|
152
152
|
return "cpu"
|
|
153
153
|
else:
|
|
154
|
-
raise RuntimeError("Invalid argument type
|
|
154
|
+
raise RuntimeError(f"Invalid argument type: {type(a)}")
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
def get_complement_device(device: DeviceLike) -> DeviceLike:
|
DepthTensor/tensor.py
CHANGED
|
@@ -26,6 +26,7 @@ from ._core import (
|
|
|
26
26
|
power,
|
|
27
27
|
clip,
|
|
28
28
|
abs,
|
|
29
|
+
mean,
|
|
29
30
|
# * diff (elementwise)
|
|
30
31
|
add_diff,
|
|
31
32
|
subtract_diff,
|
|
@@ -34,6 +35,7 @@ from ._core import (
|
|
|
34
35
|
divide_diff,
|
|
35
36
|
power_diff,
|
|
36
37
|
abs_diff,
|
|
38
|
+
mean_diff,
|
|
37
39
|
# * comparison
|
|
38
40
|
equal,
|
|
39
41
|
not_equal,
|
|
@@ -76,12 +78,13 @@ def _wrapper_2in_1out(
|
|
|
76
78
|
|
|
77
79
|
def _wrapper_1in_1out(
|
|
78
80
|
y: Tensor,
|
|
79
|
-
diff_func: Callable
|
|
81
|
+
diff_func: Callable,
|
|
80
82
|
x: OperandLike,
|
|
81
83
|
record_op: bool = True,
|
|
84
|
+
**kwargs: Any,
|
|
82
85
|
):
|
|
83
86
|
if record_op:
|
|
84
|
-
return diff_func(y, x)
|
|
87
|
+
return diff_func(y, x, **kwargs)
|
|
85
88
|
return y
|
|
86
89
|
|
|
87
90
|
|
|
@@ -311,6 +314,35 @@ class Tensor:
|
|
|
311
314
|
subok=subok,
|
|
312
315
|
)
|
|
313
316
|
|
|
317
|
+
def mean(
|
|
318
|
+
self,
|
|
319
|
+
/,
|
|
320
|
+
axis: Optional[AxisLike] = None,
|
|
321
|
+
dtype: Optional[DTypeLike] = None,
|
|
322
|
+
out: Optional[NDArrayLike] = None,
|
|
323
|
+
keepdims: bool = False,
|
|
324
|
+
*,
|
|
325
|
+
device: Optional[DeviceLike] = None,
|
|
326
|
+
in_place: bool = False,
|
|
327
|
+
where: Union[bool, NDArrayLikeBool] = True,
|
|
328
|
+
) -> Tensor:
|
|
329
|
+
return _wrapper_1in_1out(
|
|
330
|
+
mean(
|
|
331
|
+
self,
|
|
332
|
+
axis=axis,
|
|
333
|
+
dtype=dtype,
|
|
334
|
+
out=out,
|
|
335
|
+
keepdims=keepdims,
|
|
336
|
+
device=device,
|
|
337
|
+
in_place=in_place,
|
|
338
|
+
where=where,
|
|
339
|
+
),
|
|
340
|
+
mean_diff,
|
|
341
|
+
self,
|
|
342
|
+
axis=axis,
|
|
343
|
+
keepdims=keepdims,
|
|
344
|
+
)
|
|
345
|
+
|
|
314
346
|
###
|
|
315
347
|
### Reduction
|
|
316
348
|
###
|
|
@@ -407,7 +439,7 @@ class Tensor:
|
|
|
407
439
|
def __iadd__(self, t: OperandLike) -> Tensor:
|
|
408
440
|
if self.requires_grad:
|
|
409
441
|
raise RuntimeError(
|
|
410
|
-
"In-place operations are forbidden on differentiable tensors."
|
|
442
|
+
"In-place operations are (add) forbidden on differentiable tensors."
|
|
411
443
|
)
|
|
412
444
|
return add(self, t, in_place=True)
|
|
413
445
|
|
|
@@ -424,7 +456,7 @@ class Tensor:
|
|
|
424
456
|
def __isub__(self, t: OperandLike) -> Tensor:
|
|
425
457
|
if self.requires_grad:
|
|
426
458
|
raise RuntimeError(
|
|
427
|
-
"In-place operations are forbidden on differentiable tensors."
|
|
459
|
+
"In-place operations (sub) are forbidden on differentiable tensors."
|
|
428
460
|
)
|
|
429
461
|
return subtract(self, t, in_place=True)
|
|
430
462
|
|
|
@@ -441,7 +473,7 @@ class Tensor:
|
|
|
441
473
|
def __imul__(self, t: OperandLike) -> Tensor:
|
|
442
474
|
if self.requires_grad:
|
|
443
475
|
raise RuntimeError(
|
|
444
|
-
"In-place operations are forbidden on differentiable tensors."
|
|
476
|
+
"In-place operations are (mul) forbidden on differentiable tensors."
|
|
445
477
|
)
|
|
446
478
|
return multiply(self, t, in_place=True)
|
|
447
479
|
|
|
@@ -458,7 +490,7 @@ class Tensor:
|
|
|
458
490
|
def __imatmul__(self, t: OperandLike) -> Tensor:
|
|
459
491
|
if self.requires_grad:
|
|
460
492
|
raise RuntimeError(
|
|
461
|
-
"In-place operations are forbidden on differentiable tensors."
|
|
493
|
+
"In-place operations are (matmul) forbidden on differentiable tensors."
|
|
462
494
|
)
|
|
463
495
|
return matmul(self, t, in_place=True)
|
|
464
496
|
|
|
@@ -475,7 +507,7 @@ class Tensor:
|
|
|
475
507
|
def __itruediv__(self, t: OperandLike) -> Tensor:
|
|
476
508
|
if self.requires_grad:
|
|
477
509
|
raise RuntimeError(
|
|
478
|
-
"In-place operations are forbidden on differentiable tensors."
|
|
510
|
+
"In-place operations (div) are forbidden on differentiable tensors."
|
|
479
511
|
)
|
|
480
512
|
return divide(self, t, in_place=True)
|
|
481
513
|
|
|
@@ -487,7 +519,7 @@ class Tensor:
|
|
|
487
519
|
def __ipow__(self, t: OperandLike) -> Tensor:
|
|
488
520
|
if self.requires_grad:
|
|
489
521
|
raise RuntimeError(
|
|
490
|
-
"In-place operations are forbidden on differentiable tensors."
|
|
522
|
+
"In-place operations (pow) are forbidden on differentiable tensors."
|
|
491
523
|
)
|
|
492
524
|
return power(self, t, in_place=True)
|
|
493
525
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
DepthTensor/__init__.py,sha256=
|
|
1
|
+
DepthTensor/__init__.py,sha256=9KubyfThGzNBk6OmYOBIY-FWpbMPnlpDqDn6gLZeJV8,192
|
|
2
2
|
DepthTensor/autodiff.py,sha256=7bu6i1pxhP-UCf8vGbSEYu3igGddvcso36CwlMZm9ek,1343
|
|
3
|
-
DepthTensor/tensor.py,sha256=
|
|
3
|
+
DepthTensor/tensor.py,sha256=tegh_U0JFLEcWHlXb-Q8niDUMck_kulYgSWNgkSjhBU,15924
|
|
4
4
|
DepthTensor/typing.py,sha256=y33G2zVYqenNFTC8DqSnN-_xNrcmGHX0bLNx9SU7SaA,2802
|
|
5
5
|
DepthTensor/_core/__init__.py,sha256=ujjXmKbqWK1w0z4ZZraqKPRT18cYvJmgIkUKX5poWZ0,66
|
|
6
6
|
DepthTensor/_core/exceptions.py,sha256=SUih2kMxnps282WR-Cp5y395VMrbEnSRTmDmF-TXKuE,500
|
|
7
|
-
DepthTensor/_core/utils.py,sha256=
|
|
7
|
+
DepthTensor/_core/utils.py,sha256=Z-3CNy-vo8wjBgY9VImyxPnwLrfLOZngKM3yP3JTJTw,7617
|
|
8
8
|
DepthTensor/_core/ops/__init__.py,sha256=P6jswf0ZMt3AvFxTCBSyNJ1POeizsE0_ubST8e5VUJ4,122
|
|
9
9
|
DepthTensor/_core/ops/comparison.py,sha256=HBSs3iDCkCJqW3gElCg6ZoSaaTIrjJCea0_NsvNbjdQ,6978
|
|
10
10
|
DepthTensor/_core/ops/creation.py,sha256=-E-0kNz9cXtsHZUQrxLczLQPRcBCdY2BDGIPFkvT8J8,2965
|
|
11
|
-
DepthTensor/_core/ops/diff.py,sha256=
|
|
12
|
-
DepthTensor/_core/ops/elementwise.py,sha256=
|
|
11
|
+
DepthTensor/_core/ops/diff.py,sha256=FcjIl2kz34D8zfW2EVNlMgmNpShOgoeHY382HCp7ILE,7900
|
|
12
|
+
DepthTensor/_core/ops/elementwise.py,sha256=vHANLfXGRrJH7zX8FPO3wS-EHRZjiqCwci_dqnYoKzY,18498
|
|
13
13
|
DepthTensor/_core/ops/reduction.py,sha256=ByVdx1qgACcK0D4RVEskyP-EVZwvIOLMlkzlVoavrvE,3500
|
|
14
14
|
DepthTensor/_core/random/__init__.py,sha256=CohG4TxjSQdyNXNehttlpi26wOaho5G-nAsQ_rxOfPU,24
|
|
15
15
|
DepthTensor/_core/random/generator.py,sha256=uVSCKY1-ojY5K0sOkW-hMl0sPSEeAYlivKsjss3APNM,3350
|
|
16
|
-
depthtensor-2.
|
|
17
|
-
depthtensor-2.
|
|
18
|
-
depthtensor-2.
|
|
19
|
-
depthtensor-2.
|
|
20
|
-
depthtensor-2.
|
|
16
|
+
depthtensor-2.3.0.dist-info/licenses/LICENSE,sha256=nVOKKA-cGS3cEep0UIj0fpcj3mbyIuR7EIpJ4xxPG2o,1070
|
|
17
|
+
depthtensor-2.3.0.dist-info/METADATA,sha256=0z88hjs9LCsq_7svGjHYrm4CULojL95BKgx826goMJY,577
|
|
18
|
+
depthtensor-2.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
depthtensor-2.3.0.dist-info/top_level.txt,sha256=pQe07zPOHL8D1xVDLRgAOpcoiwHxc2UvgwyyMS2SrM4,12
|
|
20
|
+
depthtensor-2.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|