diff --git a/norch/__pycache__/tensor.cpython-38.pyc b/norch/__pycache__/tensor.cpython-38.pyc index 3dc93ad..f61a489 100644 Binary files a/norch/__pycache__/tensor.cpython-38.pyc and b/norch/__pycache__/tensor.cpython-38.pyc differ diff --git a/norch/csrc/cpu.cpp b/norch/csrc/cpu.cpp index 2b70cb6..f0ad525 100644 --- a/norch/csrc/cpu.cpp +++ b/norch/csrc/cpu.cpp @@ -127,6 +127,7 @@ void zeros_like_tensor_cpu(Tensor* tensor, float* result_data) { } }*/ + void transpose_tensor_cpu(Tensor* tensor, float* result_data) { int* shape = tensor->shape; int ndim = tensor->ndim; @@ -146,7 +147,6 @@ void transpose_tensor_cpu(Tensor* tensor, float* result_data) { } result_data[idx_result] = tensor->data[idx_source]; - // Update indices indices[ndim - 1]++; for (int dim = ndim - 1; dim > 0; dim--) { if (indices[dim] == shape[dim]) { diff --git a/norch/tensor.py b/norch/tensor.py index a0323db..d22aa91 100644 --- a/norch/tensor.py +++ b/norch/tensor.py @@ -122,7 +122,7 @@ class Tensor: if requires_grad: self.grad_fn = ReshapeBackward(self) - return self + return result_data def to(self, device): self.device = device @@ -392,7 +392,7 @@ class Tensor: result_data = Tensor() result_data.tensor = result_tensor_ptr - result_data.shape = self.shape[::-1] + result_data.shape = self.shape.copy()[::-1] result_data.ndim = self.ndim result_data.device = self.device diff --git a/test.py b/test.py index bce55f0..093d5aa 100644 --- a/test.py +++ b/test.py @@ -58,9 +58,9 @@ if __name__ == "__main__": b = norch.Tensor([ [1.234, 2.123, 1.5]]) - print(a.shape) - result = a.T - print(result.shape) + #print(a.shape) + b = a.reshape([2,3,5]) + print(b.shape) #c = result.sum() #c.backward() #print(a.grad)