DepthTensor 1.4.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.4.0/src/DepthTensor.egg-info → depthtensor-1.6.0}/PKG-INFO +1 -1
- {depthtensor-1.4.0 → depthtensor-1.6.0}/pyproject.toml +1 -1
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/__init__.py +1 -1
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/creation.py +6 -4
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/reduction.py +6 -3
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/tensor.py +48 -6
- {depthtensor-1.4.0 → depthtensor-1.6.0/src/DepthTensor.egg-info}/PKG-INFO +1 -1
- depthtensor-1.6.0/src/example/example.py +5 -0
- depthtensor-1.4.0/src/example/example.py +0 -4
- {depthtensor-1.4.0 → depthtensor-1.6.0}/LICENSE +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/README.md +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/setup.cfg +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/__init__.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/exceptions.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/__init__.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/comparison.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/diff.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/ops/elementwise.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/random/__init__.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/random/generator.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/_core/utils.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/autodiff.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor/typing.py +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor.egg-info/SOURCES.txt +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor.egg-info/dependency_links.txt +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor.egg-info/requires.txt +0 -0
- {depthtensor-1.4.0 → depthtensor-1.6.0}/src/DepthTensor.egg-info/top_level.txt +0 -0
- {depthtensor-1.4.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
|
###
|
|
@@ -5,7 +5,8 @@ from typing import (
|
|
|
5
5
|
Any,
|
|
6
6
|
Tuple,
|
|
7
7
|
Callable,
|
|
8
|
-
overload
|
|
8
|
+
overload,
|
|
9
|
+
Iterator
|
|
9
10
|
)
|
|
10
11
|
|
|
11
12
|
from .typing import (
|
|
@@ -163,6 +164,33 @@ class Tensor():
|
|
|
163
164
|
###
|
|
164
165
|
###
|
|
165
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
|
+
|
|
166
194
|
def get_device(self) -> DeviceLike:
|
|
167
195
|
return self.device
|
|
168
196
|
def is_device(self, device: DeviceLike) -> bool:
|
|
@@ -202,12 +230,13 @@ class Tensor():
|
|
|
202
230
|
/,
|
|
203
231
|
*,
|
|
204
232
|
device: DeviceLike = "cpu",
|
|
233
|
+
requires_grad: bool = False,
|
|
205
234
|
dtype: Optional[DTypeLike] = None,
|
|
206
235
|
order: Order = 'K',
|
|
207
236
|
subok: bool = True,
|
|
208
237
|
shape: Optional[AxisShapeLike] = None
|
|
209
238
|
) -> Tensor:
|
|
210
|
-
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)
|
|
211
240
|
|
|
212
241
|
@staticmethod
|
|
213
242
|
def ones_like(
|
|
@@ -215,12 +244,13 @@ class Tensor():
|
|
|
215
244
|
/,
|
|
216
245
|
*,
|
|
217
246
|
device: DeviceLike = "cpu",
|
|
247
|
+
requires_grad: bool = False,
|
|
218
248
|
dtype: Optional[DTypeLike] = None,
|
|
219
249
|
order: Order = 'K',
|
|
220
250
|
subok: bool = True,
|
|
221
251
|
shape: Optional[AxisShapeLike] = None
|
|
222
252
|
) -> Tensor:
|
|
223
|
-
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)
|
|
224
254
|
|
|
225
255
|
###
|
|
226
256
|
### Element-wise
|
|
@@ -675,6 +705,7 @@ class Tensor():
|
|
|
675
705
|
/,
|
|
676
706
|
*,
|
|
677
707
|
device: DeviceLike = "cpu",
|
|
708
|
+
requires_grad: bool = False,
|
|
678
709
|
axis: Optional[AxisShapeLike] = None,
|
|
679
710
|
dtype: Optional[DTypeLike] = None,
|
|
680
711
|
out: Optional[Union[np.ndarray, Any]] = None,
|
|
@@ -682,7 +713,7 @@ class Tensor():
|
|
|
682
713
|
initial: Any = _NoValue,
|
|
683
714
|
where: Union[bool, ArrayLikeBool] = True
|
|
684
715
|
) -> Tensor:
|
|
685
|
-
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)
|
|
686
717
|
|
|
687
718
|
@staticmethod
|
|
688
719
|
def max(
|
|
@@ -690,13 +721,14 @@ class Tensor():
|
|
|
690
721
|
/,
|
|
691
722
|
*,
|
|
692
723
|
device: DeviceLike = "cpu",
|
|
724
|
+
requires_grad: bool = False,
|
|
693
725
|
axis: Optional[ShapeLike] = None,
|
|
694
726
|
out: Optional[Union[np.ndarray, Any]] = None,
|
|
695
727
|
keepdims: bool = False,
|
|
696
728
|
initial: Any = _NoValue,
|
|
697
729
|
where: Union[bool, ArrayLikeBool] = True
|
|
698
730
|
) -> Tensor:
|
|
699
|
-
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)
|
|
700
732
|
|
|
701
733
|
@staticmethod
|
|
702
734
|
def maximum(
|
|
@@ -706,13 +738,14 @@ class Tensor():
|
|
|
706
738
|
out: Optional[np.ndarray] = None,
|
|
707
739
|
*,
|
|
708
740
|
device: DeviceLike = "cpu",
|
|
741
|
+
requires_grad: bool = False,
|
|
709
742
|
where: Union[bool, ArrayLikeBool] = True,
|
|
710
743
|
casting: Casting = 'same_kind',
|
|
711
744
|
order: Order = 'K',
|
|
712
745
|
dtype: Optional[DTypeLike] = None,
|
|
713
746
|
subok: bool = True
|
|
714
747
|
) -> Tensor:
|
|
715
|
-
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)
|
|
716
749
|
|
|
717
750
|
###
|
|
718
751
|
### Dunder Operations
|
|
@@ -787,6 +820,15 @@ class Tensor():
|
|
|
787
820
|
### Misc dunder
|
|
788
821
|
###
|
|
789
822
|
|
|
823
|
+
def __getitem__(self, index) -> Any:
|
|
824
|
+
return self.data[index]
|
|
825
|
+
|
|
826
|
+
def __setitem__(self, index, value) -> Any:
|
|
827
|
+
self.data[index] = value
|
|
828
|
+
|
|
829
|
+
def __iter__(self) -> Iterator:
|
|
830
|
+
return iter(self.data)
|
|
831
|
+
|
|
790
832
|
def __repr__(self) -> str:
|
|
791
833
|
return f'Tensor({self.data}, device={self.device})'
|
|
792
834
|
|
|
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
|