New proposal for handling tensor views
This is a new proposal for handling views in Tensor.
Compared to !13 (closed), this proposal does not change the interface of TensorImpl and does not require low level Extract() implementation. It also adds missing essential facilities, such as isContiguous(), makeContiguous() and refContiguous().
What is in this MR?
-
mImplis nowshared_ptrinstead ofunique_ptr, with removed dependence toTensorinTensorImpl; - Added
mImplOffsetparameter for data offset of the current Tensor w.r.t. shared implementation; - Added
mStridesparameter to Tensor; - Tensor copy-ctor and assignment operators now make a shallow copy (when possible). Added a
clone()function for deep copy; - Added 2
extract()functions for extracting a sub-tensor; - Added a
makeContiguous()function to make memory contiguous (andrefContiguous()on the same model asrefCastFrom()). -
resize()behavior currently is to throw if one tries to change de size with a shared implementation.- Alternative behavior(?): make a new implementation during resize and stop sharing previous implementation.
Edited by Olivier BICHLER