-
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
Call sparse op from python #40608
Call sparse op from python #40608
Conversation
Thanks for your contribution! |
@@ -1038,7 +1041,8 @@ def GenerateNodeCCFile(filepath, node_definition_str): | |||
#include "paddle/fluid/eager/api/generated/eager_generated/backwards/nodes.h" | |||
#include "paddle/fluid/eager/to_static/run_program_op_node.h" | |||
|
|||
#include "paddle/phi/api/include/sparse_api.h" | |||
//#include "paddle/phi/api/include/sparse_api.h" |
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.
done
Backend kernel_backend = Backend::UNDEFINED; | ||
DataLayout kernel_layout = DataLayout::UNDEFINED; | ||
DataType kernel_data_type = DataType::UNDEFINED; | ||
if (kernel_backend == Backend::UNDEFINED || | ||
kernel_layout == DataLayout::UNDEFINED || | ||
kernel_data_type == DataType::UNDEFINED) { | ||
auto kernel_key_set = ParseKernelKeyByInputArgs(x); | ||
auto kernel_key = kernel_key_set.GetHighestPriorityKernelKey(); | ||
if (kernel_backend == Backend::UNDEFINED) { | ||
kernel_backend = kernel_key.backend(); | ||
} | ||
if (kernel_layout == DataLayout::UNDEFINED) { | ||
kernel_layout = kernel_key.layout(); | ||
} | ||
if (kernel_data_type == DataType::UNDEFINED) { | ||
kernel_data_type = kernel_key.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.
如果自定义实现的话不用写的这么复杂,直接kernel_key拿出来用就行
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
@@ -83,32 +102,50 @@ Tensor to_sparse_coo_impl(const Tensor& x, | |||
out.set_impl(coo); | |||
|
|||
// 6. Call kernel | |||
VLOG(6) << "call 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.
这种内容比较少的VLOG感觉可以去掉或者把级别调大一些
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.
已把debug信息去掉。
@@ -201,7 +207,9 @@ void DenseToSparseCooKernel(const Context& dev_ctx, | |||
temp_indexs_ptr, | |||
indices_data, | |||
sparse_data); | |||
VLOG(6) << "set member"; |
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.
感觉这像是调试的log,内容不算规范
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
PR types
Others
PR changes
Others
Describe
PD_REGISTER_API(Test);
test_sparse_utils_op.py
,todo:目前是测试_C_ops
下的接口,后面需要改成paddle.sparse.
相应API。