修改库
Some checks failed
Build wheels / build (ubuntu-latest, 3.11) (push) Has been cancelled
Build wheels / build (ubuntu-latest, 3.12) (push) Has been cancelled
Build wheels / build (ubuntu-latest, 3.13) (push) Has been cancelled
Tests / check (push) Has been cancelled
Tests / build (ubuntu-latest, 3.11) (push) Has been cancelled
Tests / build (ubuntu-latest, 3.12) (push) Has been cancelled
Tests / build (ubuntu-latest, 3.13) (push) Has been cancelled
Some checks failed
Build wheels / build (ubuntu-latest, 3.11) (push) Has been cancelled
Build wheels / build (ubuntu-latest, 3.12) (push) Has been cancelled
Build wheels / build (ubuntu-latest, 3.13) (push) Has been cancelled
Tests / check (push) Has been cancelled
Tests / build (ubuntu-latest, 3.11) (push) Has been cancelled
Tests / build (ubuntu-latest, 3.12) (push) Has been cancelled
Tests / build (ubuntu-latest, 3.13) (push) Has been cancelled
This commit is contained in:
@@ -1288,28 +1288,9 @@ class QteaTorchTensor(_AbstractQteaBaseTensor):
|
||||
To be able to work with all ranks, we currently avoid the numpy
|
||||
syntax in our implementation.
|
||||
"""
|
||||
lists = []
|
||||
for ii, corner_ii in enumerate(corner_low):
|
||||
corner_jj = corner_high[ii]
|
||||
lists.append(list(range(corner_ii, corner_jj)))
|
||||
|
||||
shape = self.elem.shape
|
||||
cdim = np.cumprod(np.array(shape[::-1], dtype=int))[::-1]
|
||||
cdim = np.array(list(cdim[1:]) + [1], dtype=int)
|
||||
|
||||
# Reshape does not make a copy, but points to memory (unlike flatten)
|
||||
self_1d = self.elem.reshape(-1)
|
||||
sub_1d = tensor.elem.reshape(-1)
|
||||
|
||||
kk = -1
|
||||
for elem in itertools.product(*lists):
|
||||
kk += 1
|
||||
elem = np.array(elem, dtype=int)
|
||||
idx = np.sum(elem * cdim)
|
||||
|
||||
self_1d[idx] = sub_1d[kk]
|
||||
|
||||
# self._elem never changed shape, we are done
|
||||
slices = tuple(slice(lo, hi) for lo, hi in zip(corner_low, corner_high))
|
||||
shape = tuple(hi - lo for lo, hi in zip(corner_low, corner_high))
|
||||
self._elem[slices] = tensor.elem.reshape(shape)
|
||||
|
||||
def to_dense(self, true_copy=False):
|
||||
"""Return dense tensor (if `true_copy=False`, same object may be returned)."""
|
||||
|
||||
Reference in New Issue
Block a user