Skip to content

Conversation

zkh2016
Copy link
Contributor

@zkh2016 zkh2016 commented Mar 21, 2022

PR types

Others

PR changes

Others

Describe

  1. eager.Tensor中添加to_sparse_coo、to_sparse_csr、to_dense三个方法,用来dense和sparse互转使用。
  2. eager中添加sparse_coo_tensor和sparse_csr_tensor两个API,用来创建SparseCooTensor和SparseCsrTensor。

@paddle-bot-old
Copy link

你的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.

@zkh2016 zkh2016 changed the title Add sparse convertion api to Tensor Add sparse convertion api and sparse creation api Mar 23, 2022
@zkh2016 zkh2016 requested a review from zyfncg March 23, 2022 09:41
cc_library(sparse_api_custom_impl SRCS sparse_api_custom_impl.cc DEPS phi_tensor_raw phi kernel_dispatch api_gen_utils phi_data_transform)

cc_library(phi_function_api SRCS ${api_source_file} DEPS phi_tensor_raw phi kernel_dispatch api_gen_utils phi_data_transform api_custom_impl)
cc_library(phi_function_api SRCS ${api_source_file} DEPS phi_tensor_raw phi kernel_dispatch api_gen_utils phi_data_transform api_custom_impl sparse_api_custom_impl)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的依赖应该不需要加,普通的前向API不会依赖自定义的sparse_api

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已去掉,改成在编译tensor_methord.cc地方添加依赖。

Comment on lines 523 to 546
/* Part 11: Methods of converting SparseTensor and DenseTensor to each other
*/
/**
* @brief Convert DenseTensor or SparseCsrTensor to SparseCooTensor
*
* @param sparse_dim, The number of sparse dimensions
* @return Tensor
*/
Tensor to_sparse_coo(const int64_t sparse_dim);

/**
* @brief Convert DenseTensor or SparseCooTensor to SparseCsrTensor
*
* @return Tensor
*/
Tensor to_sparse_csr();

/**
* @brief Convert SparseCooTensor or SparseCsrTensor to DenseTensor
*
* @return Tensor
*/
Tensor to_dense();

Copy link
Contributor

@zyfncg zyfncg Mar 23, 2022

Choose a reason for hiding this comment

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

这几个方法标记成 const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@zkh2016 zkh2016 closed this Mar 24, 2022
@zkh2016 zkh2016 reopened this Mar 24, 2022
@zkh2016 zkh2016 merged commit a8f8660 into PaddlePaddle:develop Mar 24, 2022
return ToPyObject(coo_tensor);
EAGER_CATCH_AND_THROW_RETURN_NULL
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot find this method "tensor_method_to_sparse_coo" in
paddle\fluid\pybind\eager_method.cc on the "develop" branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'to_sparse_coo' has been move to varbase_patch_methods.py

return ToPyObject(dense_tensor);
EAGER_CATCH_AND_THROW_RETURN_NULL
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Now, I cannot find "tensor_method_to_dense" in paddle\fluid\pybind\eager_method.cc on
the "develop" branch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

‘to_dense' has been move to varbase_patch_methods.py

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.

4 participants