Skip to content

Conversation

@zkh2016
Copy link
Contributor

@zkh2016 zkh2016 commented Sep 14, 2022

PR types

Others

PR changes

Others

Describe

  1. SparseCooTensor和SparseCsrTensor添加SparseTensorMeta
  2. 添加路径:infermeta/sparse/,添加相应的infer_meta方法
  3. sparse_api_gen.py添加生成infer_meta的代码
  4. yaml配置infer_meta

@paddle-bot
Copy link

paddle-bot bot commented Sep 14, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.


return kernel_context_code

def gene_infer_meta(self, kernel_output_names, code_indent) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数里面大部分代码和现有代码差不多,感觉可以做一些复用

}

protected:
SparseTensorMeta meta_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta_成员为什么是protected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已改成private


DDim dims;
DataType dtype;
DataLayout layout{DataLayout::NCHW};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sparseTensor好像不需要layout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个layout主要用来保留dense的layout,为了to_dense的时候能够转回正确的layout

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

phi::MetaTensor meta_out(impl_.get());
phi::UnchangedInferMeta(
MakeMetaTensor(
*(std::static_pointer_cast<phi::SparseCooTensor>(src.impl_))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是可以不用cast?

@zkh2016 zkh2016 mentioned this pull request Sep 16, 2022
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zkh2016 zkh2016 merged commit 4b95f85 into PaddlePaddle:develop Sep 19, 2022
zkh2016 pushed a commit to zkh2016/Paddle that referenced this pull request Sep 19, 2022
lanxianghit pushed a commit that referenced this pull request Sep 20, 2022
cherry-pick : #46016, #46021, #45974

* [Sparse]Sparse add support gpu (#45974)

* [Sparse]Remove unused code (#46021)

* [Sparse] Add infer meta (#46016)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants