Smart Tensor Reallocation (CUDA)
Description
TLDR: similar to aidge_core!490 (merged) but for the CUDA backend
Current tensor implementation uses lazy initialization : internally, a call of lazyInit()
is performed when a tensor re-allocation is needed. This is the case when one tries to access a tensor data after a resize
has been called.
Until now, policy regarding reallocation has been to reset the data ptr, without filling the uninitialized memory.
Through this MR, we propose to smartly reinitialize the data, by reusing previous values and filling spares with zeros.
Note that this approach is the one chosen by the STL for the implementation of the std::vector
.
This new behaviour helps adressing aidge_learning#26 (closed), as the grad tensor, which is resized after a forwardDims
, will now be filled with zeros.
A similar MR has been done for the smart reallocation of CPU tensors : aidge_core!490 (merged)
Files modified : TensorImpl.hpp