[TensorV2] Enable copying data from Tensor
authorDonghyeon Jeong <dhyeon.jeong@samsung.com>
Fri, 19 Jan 2024 10:40:02 +0000 (19:40 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Wed, 24 Jan 2024 23:15:24 +0000 (08:15 +0900)
commitb1293905f9008617354ab27f0c6d1fb812fa7d4b
tree8e570d124a9cb1008110ffa9627c9ce5f44b9eb8
parent688ff453b6d231964be056fcad58d7823d65bdf4
[TensorV2] Enable copying data from Tensor

This PR enables deep copy functionalities of a contiguous tensor with the following functions. copy(), copyData(), and copy_with_strides().

The copy function completely copies the target tensor values regardless of the dimension of the input tensor. All elements and properties of the original tensor are copied to the new tensor. Therefore, if the copy function is used, a new tensor with the same size and shape as the original tensor is created.

On the other hand, the copyData function must match the size of the input and target tensors. This function only copies the data of the original tenor, so if the size or shape of the tensor is different, the copy may not be done properly.

Note that copy and copyData functions support copy data from multiple tensor data types while the copy_with_strides function only supports copying data from the same data type.

**Self-evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test:   [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Donghyeon Jeong <dhyeon.jeong@samsung.com>
nntrainer/tensor/float_tensor.cpp
nntrainer/tensor/float_tensor.h
nntrainer/tensor/half_tensor.cpp
nntrainer/tensor/half_tensor.h
nntrainer/tensor/tensor_base.h
nntrainer/tensor/tensor_v2.cpp
nntrainer/tensor/tensor_v2.h