-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove detail from LODTensor #3364
Conversation
paddle/framework/lod_tensor_impl.h
Outdated
namespace paddle { | ||
namespace framework { | ||
|
||
namespace detail { | ||
|
||
using LOD = LODTensor::LOD; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No using
in header files.
paddle/framework/lod_tensor_impl.h
Outdated
* @level_begin: level to begin slice. | ||
* @level_end: level to end slice. | ||
*/ | ||
LOD SliceLOD(const LODTensor::LOD &lod, size_t level_begin, size_t level_end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems more reasonable to make SliceLOD
a method of class LOD LOD::Slice
.
paddle/framework/lod_tensor_impl.h
Outdated
* @elem_begin: element's index to begin slice. | ||
* @elem_end: element's index to end slice. | ||
*/ | ||
LOD SliceLOD(const LODTensor::LOD &lod, size_t level, size_t elem_begin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems more reasonable if SliceLOD
is a method of LOD: LOD::Slice
.
paddle/framework/lod_tensor_impl.h
Outdated
|
||
return LODTensor(new_tensor, new_lod); | ||
LODTensor LODTensor::SliceLevels(size_t level_begin, size_t level_end) const { | ||
auto new_lod = detail::SliceLOD(lod_start_pos_, level_begin, level_end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that if we can fix #3376, then L47 to L52 could be merged into one line?
return LODTensor(lod_.Slice(level_begin, level_end)).ShareDataWith<T>(*this);
paddle/framework/lod_tensor_impl.h
Outdated
auto sliced_tensor = tensor_->Slice<T>(start_idx, end_idx); | ||
auto new_tensor = std::make_shared<Tensor>(); | ||
new_tensor->CopyFrom<T>(sliced_tensor, dst_place); | ||
// slice elements just need to update LOD info, because offsets are not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slice elements ... => Slice elements ...
paddle/framework/variable.h
Outdated
@@ -37,6 +38,12 @@ class Variable { | |||
return static_cast<T*>(holder_->Ptr()); | |||
} | |||
|
|||
void CloneTensorType(const Variable& other) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template <typename T>
void Assign(const Variable& v) {
holder_.reset(new PlaceholderImpl<T>(v.Get()));
}
template <typename T>
void Assign(T* v) {
holder_.reset(new PlaceholderImpl<T>(v));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! need following PRs to complete this.
fix: #3441