DepthTensor 1.5.0__tar.gz → 1.6.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.
- {depthtensor-1.5.0/src/DepthTensor.egg-info → depthtensor-1.6.0}/PKG-INFO +1 -1
- {depthtensor-1.5.0 → depthtensor-1.6.0}/pyproject.toml +1 -1
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/__init__.py +1 -1
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/creation.py +6 -4
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/reduction.py +6 -3
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/tensor.py +37 -5
- {depthtensor-1.5.0 → depthtensor-1.6.0/src/DepthTensor.egg-info}/PKG-INFO +1 -1
- {depthtensor-1.5.0 → depthtensor-1.6.0}/LICENSE +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/README.md +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/setup.cfg +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/__init__.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/exceptions.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/__init__.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/comparison.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/diff.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/elementwise.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/random/__init__.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/random/generator.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/_core/utils.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/autodiff.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor/typing.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor.egg-info/SOURCES.txt +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor.egg-info/dependency_links.txt +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor.egg-info/requires.txt +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/DepthTensor.egg-info/top_level.txt +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/src/example/example.py +0 -0
- {depthtensor-1.5.0 → depthtensor-1.6.0}/tests/test_tensor.py +0 -0
|
@@ -32,6 +32,7 @@ def zeros_like(
|
|
|
32
32
|
/,
|
|
33
33
|
*,
|
|
34
34
|
device: DeviceLike = "cpu",
|
|
35
|
+
requires_grad: bool = False,
|
|
35
36
|
dtype: Optional[DTypeLike] = None,
|
|
36
37
|
order: Order = 'K',
|
|
37
38
|
subok: bool = True,
|
|
@@ -46,14 +47,14 @@ def zeros_like(
|
|
|
46
47
|
if device_op == "cpu":
|
|
47
48
|
return Tensor(
|
|
48
49
|
np.zeros_like(a, dtype=dtype, order=order, subok=subok, shape=shape),
|
|
49
|
-
device=device_op
|
|
50
|
+
device=device_op, requires_grad=requires_grad
|
|
50
51
|
)
|
|
51
52
|
else:
|
|
52
53
|
if cp is None: raise CuPyNotFound(CUPY_NOT_FOUND_MSG)
|
|
53
54
|
return Tensor(
|
|
54
55
|
#! As of the time writing this, CuPy does not support subok.
|
|
55
56
|
cp.zeros_like(a, dtype=dtype, order=order, subok=None, shape=shape),
|
|
56
|
-
device=device_op
|
|
57
|
+
device=device_op, requires_grad=requires_grad
|
|
57
58
|
)
|
|
58
59
|
|
|
59
60
|
def ones_like(
|
|
@@ -61,6 +62,7 @@ def ones_like(
|
|
|
61
62
|
/,
|
|
62
63
|
*,
|
|
63
64
|
device: DeviceLike = "cpu",
|
|
65
|
+
requires_grad: bool = False,
|
|
64
66
|
dtype: Optional[DTypeLike] = None,
|
|
65
67
|
order: Order = 'K',
|
|
66
68
|
subok: bool = True,
|
|
@@ -75,14 +77,14 @@ def ones_like(
|
|
|
75
77
|
if device_op == "cpu":
|
|
76
78
|
return Tensor(
|
|
77
79
|
np.ones_like(a, dtype=dtype, order=order, subok=subok, shape=shape),
|
|
78
|
-
device=device_op
|
|
80
|
+
device=device_op, requires_grad=requires_grad
|
|
79
81
|
)
|
|
80
82
|
else:
|
|
81
83
|
if cp is None: raise CuPyNotFound(CUPY_NOT_FOUND_MSG)
|
|
82
84
|
return Tensor(
|
|
83
85
|
#! As of the time writing this, CuPy does not support subok.
|
|
84
86
|
cp.zeros_like(a, dtype=dtype, order=order, subok=None, shape=shape),
|
|
85
|
-
device=device_op
|
|
87
|
+
device=device_op, requires_grad=requires_grad
|
|
86
88
|
)
|
|
87
89
|
|
|
88
90
|
###
|
|
@@ -41,6 +41,7 @@ def sum(
|
|
|
41
41
|
/,
|
|
42
42
|
*,
|
|
43
43
|
device: DeviceLike = "cpu",
|
|
44
|
+
requires_grad: bool = False,
|
|
44
45
|
axis: Optional[AxisShapeLike] = None,
|
|
45
46
|
dtype: Optional[DTypeLike] = None,
|
|
46
47
|
out: Optional[Union[np.ndarray, Any]] = None,
|
|
@@ -70,13 +71,14 @@ def sum(
|
|
|
70
71
|
else:
|
|
71
72
|
if cp is None: raise CuPyNotFound(CUPY_NOT_FOUND_MSG)
|
|
72
73
|
y = cp.sum(arr, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
|
|
73
|
-
return Tensor(y, device=device_op)
|
|
74
|
+
return Tensor(y, device=device_op, requires_grad=requires_grad)
|
|
74
75
|
|
|
75
76
|
def max(
|
|
76
77
|
a: OperandLike,
|
|
77
78
|
/,
|
|
78
79
|
*,
|
|
79
80
|
device: DeviceLike = "cpu",
|
|
81
|
+
requires_grad: bool = False,
|
|
80
82
|
axis: Optional[ShapeLike] = None,
|
|
81
83
|
out: Optional[Union[np.ndarray, Any]] = None,
|
|
82
84
|
keepdims: bool = False,
|
|
@@ -95,7 +97,7 @@ def max(
|
|
|
95
97
|
else:
|
|
96
98
|
if cp is None: raise CuPyNotFound(CUPY_NOT_FOUND_MSG)
|
|
97
99
|
y = cp.max(arr, axis=axis, out=out, keepdims=keepdims)
|
|
98
|
-
return Tensor(y, device=device_op)
|
|
100
|
+
return Tensor(y, device=device_op, requires_grad=requires_grad)
|
|
99
101
|
|
|
100
102
|
def maximum(
|
|
101
103
|
x1: OperandLike,
|
|
@@ -104,6 +106,7 @@ def maximum(
|
|
|
104
106
|
out: Optional[np.ndarray] = None,
|
|
105
107
|
*,
|
|
106
108
|
device: DeviceLike = "cpu",
|
|
109
|
+
requires_grad: bool = False,
|
|
107
110
|
where: Union[bool, ArrayLikeBool] = True,
|
|
108
111
|
casting: Casting = 'same_kind',
|
|
109
112
|
order: Order = 'K',
|
|
@@ -126,7 +129,7 @@ def maximum(
|
|
|
126
129
|
y = np.maximum(x1, x2, out=out, dtype=dtype, where=where, casting=casting, order=order, subok=subok)
|
|
127
130
|
else:
|
|
128
131
|
y = np.maximum(x1, x2, out=out, dtype=dtype, casting=casting)
|
|
129
|
-
return Tensor(y, device=device_op)
|
|
132
|
+
return Tensor(y, device=device_op, requires_grad=requires_grad)
|
|
130
133
|
|
|
131
134
|
###
|
|
132
135
|
###
|
|
@@ -164,6 +164,33 @@ class Tensor():
|
|
|
164
164
|
###
|
|
165
165
|
###
|
|
166
166
|
|
|
167
|
+
def copy(
|
|
168
|
+
self,
|
|
169
|
+
*,
|
|
170
|
+
order: Order = "K",
|
|
171
|
+
dtype: Optional[DTypeLike] = None,
|
|
172
|
+
device: Optional[DeviceLike] = None,
|
|
173
|
+
copy_prev: bool = False,
|
|
174
|
+
copy_requires_grad: bool = False,
|
|
175
|
+
copy_grad: bool = False
|
|
176
|
+
) -> Tensor:
|
|
177
|
+
t = Tensor(
|
|
178
|
+
self.data.copy(order=order),
|
|
179
|
+
dtype=self.dtype if dtype is None else dtype,
|
|
180
|
+
device=self.device if device is None else device,
|
|
181
|
+
prev=self.prev if copy_prev else (),
|
|
182
|
+
requires_grad=self.requires_grad if copy_requires_grad else False
|
|
183
|
+
)
|
|
184
|
+
if copy_grad:
|
|
185
|
+
t.grad = self.grad
|
|
186
|
+
return t
|
|
187
|
+
|
|
188
|
+
def to_device(self, device: DeviceLike) -> Tensor:
|
|
189
|
+
if device == self.device:
|
|
190
|
+
return self.copy()
|
|
191
|
+
else:
|
|
192
|
+
return self.copy(device=device)
|
|
193
|
+
|
|
167
194
|
def get_device(self) -> DeviceLike:
|
|
168
195
|
return self.device
|
|
169
196
|
def is_device(self, device: DeviceLike) -> bool:
|
|
@@ -203,12 +230,13 @@ class Tensor():
|
|
|
203
230
|
/,
|
|
204
231
|
*,
|
|
205
232
|
device: DeviceLike = "cpu",
|
|
233
|
+
requires_grad: bool = False,
|
|
206
234
|
dtype: Optional[DTypeLike] = None,
|
|
207
235
|
order: Order = 'K',
|
|
208
236
|
subok: bool = True,
|
|
209
237
|
shape: Optional[AxisShapeLike] = None
|
|
210
238
|
) -> Tensor:
|
|
211
|
-
return zeros_like(a, device=device, dtype=dtype, order=order, subok=subok, shape=shape)
|
|
239
|
+
return zeros_like(a, device=device, requires_grad=requires_grad, dtype=dtype, order=order, subok=subok, shape=shape)
|
|
212
240
|
|
|
213
241
|
@staticmethod
|
|
214
242
|
def ones_like(
|
|
@@ -216,12 +244,13 @@ class Tensor():
|
|
|
216
244
|
/,
|
|
217
245
|
*,
|
|
218
246
|
device: DeviceLike = "cpu",
|
|
247
|
+
requires_grad: bool = False,
|
|
219
248
|
dtype: Optional[DTypeLike] = None,
|
|
220
249
|
order: Order = 'K',
|
|
221
250
|
subok: bool = True,
|
|
222
251
|
shape: Optional[AxisShapeLike] = None
|
|
223
252
|
) -> Tensor:
|
|
224
|
-
return ones_like(a, device=device, dtype=dtype, order=order, subok=subok, shape=shape)
|
|
253
|
+
return ones_like(a, device=device, requires_grad=requires_grad, dtype=dtype, order=order, subok=subok, shape=shape)
|
|
225
254
|
|
|
226
255
|
###
|
|
227
256
|
### Element-wise
|
|
@@ -676,6 +705,7 @@ class Tensor():
|
|
|
676
705
|
/,
|
|
677
706
|
*,
|
|
678
707
|
device: DeviceLike = "cpu",
|
|
708
|
+
requires_grad: bool = False,
|
|
679
709
|
axis: Optional[AxisShapeLike] = None,
|
|
680
710
|
dtype: Optional[DTypeLike] = None,
|
|
681
711
|
out: Optional[Union[np.ndarray, Any]] = None,
|
|
@@ -683,7 +713,7 @@ class Tensor():
|
|
|
683
713
|
initial: Any = _NoValue,
|
|
684
714
|
where: Union[bool, ArrayLikeBool] = True
|
|
685
715
|
) -> Tensor:
|
|
686
|
-
return sum(a, axis=axis, device=device, dtype=dtype, out=out, keepdims=keepdims, initial=initial, where=where)
|
|
716
|
+
return sum(a, axis=axis, device=device, requires_grad=requires_grad, dtype=dtype, out=out, keepdims=keepdims, initial=initial, where=where)
|
|
687
717
|
|
|
688
718
|
@staticmethod
|
|
689
719
|
def max(
|
|
@@ -691,13 +721,14 @@ class Tensor():
|
|
|
691
721
|
/,
|
|
692
722
|
*,
|
|
693
723
|
device: DeviceLike = "cpu",
|
|
724
|
+
requires_grad: bool = False,
|
|
694
725
|
axis: Optional[ShapeLike] = None,
|
|
695
726
|
out: Optional[Union[np.ndarray, Any]] = None,
|
|
696
727
|
keepdims: bool = False,
|
|
697
728
|
initial: Any = _NoValue,
|
|
698
729
|
where: Union[bool, ArrayLikeBool] = True
|
|
699
730
|
) -> Tensor:
|
|
700
|
-
return max(a, axis=axis, device=device, out=out, keepdims=keepdims, initial=initial, where=where)
|
|
731
|
+
return max(a, axis=axis, device=device, requires_grad=requires_grad, out=out, keepdims=keepdims, initial=initial, where=where)
|
|
701
732
|
|
|
702
733
|
@staticmethod
|
|
703
734
|
def maximum(
|
|
@@ -707,13 +738,14 @@ class Tensor():
|
|
|
707
738
|
out: Optional[np.ndarray] = None,
|
|
708
739
|
*,
|
|
709
740
|
device: DeviceLike = "cpu",
|
|
741
|
+
requires_grad: bool = False,
|
|
710
742
|
where: Union[bool, ArrayLikeBool] = True,
|
|
711
743
|
casting: Casting = 'same_kind',
|
|
712
744
|
order: Order = 'K',
|
|
713
745
|
dtype: Optional[DTypeLike] = None,
|
|
714
746
|
subok: bool = True
|
|
715
747
|
) -> Tensor:
|
|
716
|
-
return maximum(x1, x2, out=out, device=device, where=where, casting=casting, order=order, dtype=dtype, subok=subok)
|
|
748
|
+
return maximum(x1, x2, out=out, device=device, requires_grad=requires_grad, where=where, casting=casting, order=order, dtype=dtype, subok=subok)
|
|
717
749
|
|
|
718
750
|
###
|
|
719
751
|
### Dunder Operations
|
|
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
|