-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Unify Tensors PR #3]Port framework::Tensor members & interfaces to pten::DenseTensor, test=allcases #38473
[Unify Tensors PR #3]Port framework::Tensor members & interfaces to pten::DenseTensor, test=allcases #38473
Conversation
…faces accordingly
… allocation_rearrange_pr
… allocation_rearrange_pr
… allocation_rearrange_pr PaddlePaddle#2
… allocation_rearrange_pr
… densetensor_interface_change
…to pten::DenseTensor
Thanks for your contribution! |
… densetensor_interface_change
55445ad
to
3298585
Compare
d22b544
to
41ada84
Compare
41ada84
to
235503f
Compare
meta_.offset = 0; | ||
} | ||
|
||
DenseTensor::DenseTensor(const paddle::framework::proto::VarType::Type& dtype) { |
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.
这里建议不用第三方库的类型
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.
暂时保留对protobuf的依赖,1月底前完成清理。已在TrickList中追踪。
return Split(split_size, axis); | ||
} | ||
|
||
void* DenseTensor::mutable_data(const paddle::platform::Place& place, |
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.
同上
|
||
DenseTensor(); | ||
|
||
explicit DenseTensor(const paddle::framework::proto::VarType::Type& dtype); |
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.
同上
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.
暂时保留对protobuf的依赖,1月底前完成清理。已在TrickList中追踪。
|
||
Will be adjusted/removed/moved in the near future | ||
*/ | ||
public: |
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.
EigenTensor / EigenMatrix / EigenVector 友元类请在后续调整去除
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.
已删除
|
||
std::vector<DenseTensor> Chunk(int64_t chunks, int64_t axis) const; | ||
|
||
paddle::framework::proto::VarType::Type type() const; |
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.
同上
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.
暂时保留对protobuf的依赖,1月底前完成清理。已在TrickList中追踪。
… densetensor_interface_change
fa0f020
to
ab4e4a7
Compare
… densetensor_interface_change
… densetensor_interface_change
… densetensor_interface_change
… densetensor_interface_change
… densetensor_interface_change
meta_.dims = dims; | ||
mutable_data(); | ||
if (storage_ != nullptr) { |
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.
这里如果直接默认构造一个DenseTensor,然后调用resize,是不是没有实际发挥作用,且不会有任何提示,建议在后续PR增加报错提示
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.
Resize函数定义里加了一个注释。本质上这里是暂时兼容两种用法:
- pten用法:用Allocator初始化DenseTensor,则Resize不仅修改dims还会直接分配内存
- fluid用法:默认构造DenseTensor,place未知,则延迟到调用mutable_data(place)时再行分配内存
size_t requested_size = 0); | ||
|
||
template <typename T> | ||
T* mutable_data(const DDim& dims, |
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.
后续可以在不希望被pten kernel使用、仅用于兼容的方法上均增加注释提示,避免迁移kernel时误用
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.
下一个PR里会补充相应注释。
data_ = holder; | ||
} | ||
|
||
std::shared_ptr<paddle::memory::Allocation> move_data_shared() { |
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.
请问这里是不是返回 shared_ptr&&
好一些
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.
感谢!提交一个后续Patch进行修改。
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 for allocshared
PR types
New features
PR changes
Others
Describe
Port framework::Tensor members & interfaces to pten::DenseTensor