-
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
Add sparse convertion api and sparse creation api #40780
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
paddle/phi/api/lib/CMakeLists.txt
Outdated
@@ -143,7 +143,7 @@ cc_library(phi_data_transform SRCS data_transform.cc DEPS phi_tensor_raw transfe | |||
cc_library(api_custom_impl SRCS api_custom_impl.cc DEPS phi_tensor_raw phi kernel_dispatch api_gen_utils phi_data_transform) | |||
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) |
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.
这里的依赖应该不需要加,普通的前向API不会依赖自定义的sparse_api
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.
已去掉,改成在编译tensor_methord.cc地方添加依赖。
paddle/phi/api/include/tensor.h
Outdated
/* 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(); | ||
|
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.
这几个方法标记成 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.
done
return ToPyObject(coo_tensor); | ||
EAGER_CATCH_AND_THROW_RETURN_NULL | ||
} | ||
|
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.
I cannot find this method "tensor_method_to_sparse_coo" in
paddle\fluid\pybind\eager_method.cc on the "develop" branch.
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.
'to_sparse_coo' has been move to varbase_patch_methods.py
return ToPyObject(dense_tensor); | ||
EAGER_CATCH_AND_THROW_RETURN_NULL | ||
} | ||
|
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.
Now, I cannot find "tensor_method_to_dense" in paddle\fluid\pybind\eager_method.cc on
the "develop" branch
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.
‘to_dense' has been move to varbase_patch_methods.py
PR types
Others
PR changes
Others
Describe