1. Add template T which indicates data type to `CopyFrom()`, `Slice()`
and `ShareData()` functions. This makes `CopyData()` code much clearer.
2. Add `set_dim()`.
3. `product(DDim)` transforms `DDim` to `vector<int>` first and then calculate
its product. That might be quite slow. For `product(dims_)` is frequently
used in Tensor, we add a mumber variable `numel_` as a cache of the
product result.
TODO: refactor `product()` to make it more efficient.
4. Unable Tensor::operator=
5. Remove the limit of POD type, because `float16` and `int8` are not POD type.
1. Add `Tensor::CopyFrom`. Current version can only support CPU memory
copy. The support of GPU will be provided later by `paddle::memory`.
The current implementation of `Tensor::CopyFrom` is a little inefficient:
Every time `CopyFrom` is called, tensor will re-allocate its memory. However, if
we try to check and reuse `placeholder_`, we have to provide a template
parameter for `CopyFrom` to indicate the data type. It seems strange for
a simple copy function.
2. Add `Tensor::mutable_data(Place place)`, which directly use member
variable `dims_` as its dim parameter. This interface is required by
`Op::InferShape`.
1. Add member variable 'DDim dims_' and a getter function 'dims()'.
'dims' is supposed to hold tensor's shape during Op::InferShape.
2. Remove 'mutable_data' which use default Place. User must specify a
explicit Place when call 'mutable_data'.
3. A PlaceHolder may be shared by more than one tensor, and some of them may be the others' slices. So we add a new member variable 'offset_' for Tensor, which is used to show the byte offset between PlaceHolder::ptr_ and where tensor's data really begins.
4. Add functions 'ShareDataFrom' and 'Slice' for Tensor.
TODO: Tensor needs a 'CopyFrom' function.