-
Notifications
You must be signed in to change notification settings - Fork 274
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
[实现飞桨框架动态图反向图的可视化] 设计文档 #535
Conversation
哈喽 请问这个项目你们完成的进度怎么样了,队里几个人呀 |
进度是目前只写了一个RFC文档, 导师还没有进行审核. 目前项目进展有个难点, 对于paddle中python调用c++的流程细节还没有梳理清楚, 目前还不能进行调试 |
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.
设计文档还需要细化:
- 获取paddle的反向图的节点信息
- 将反向图的节点信息暴露给pythonAPI
这两点是本项目的难点: - tensor.grad_fn 应该在paddle/fluid/pybind/eager_properties.cc中实现。可以通过:
auto meta = egr::EagerUtils::nullable_autograd_meta(self->tensor);
meta.GradNode()
获取到GradNode - 需要参考paddle/fluid/pybind/eager.cc中的BindEager函数。将GradNode作为一个类型暴露给Python。BindEager通过调用PyModule_AddObject将Tensor暴露给了Python。你可以参考一下。
- next_functions是GradNode暴露到Python端的类型的一个属性。需要参考paddle/fluid/pybind/eager_properties.cc实现。eager_properties.cc里是将Tensor的属性暴露的具体实现源码。
- next_functions需要获取GradNode的后继节点的所有GradNode。获取方法可以参考:
const paddle::small_vector<std::vector, kSlotSmallVectorSize>& metas = node->OutputMeta();
for (const auto& meta_list : metas) {
for (const GradSlotMeta& meta : meta_list) {
const auto& edge = meta.GetEdge();
GradNodeBase* next_node = edge.GetMutableGradNode().get();
}
}
实现。
python调用c++的流程是不是可以通过开发成c++算子实现? |
流程应该是一致的, 将c++实现的函数 暴露出来给到python进行调用. |
@ZS-YANG 如果有兴趣参加,可以联系运营加群 |
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.
我觉得这个方案已经具备开始开发的条件了过程中遇到具体问题咱们再讨论解决
// Get the GradNode from meta | ||
auto grad_node = meta.GradNode(); // Convert GradNode to a Python object | ||
// The conversion will depend on the structure of GradNode. | ||
PyObject* py_grad_node = GradooNodeToPyObject(grad_node); // You need to implement GradooNodeToPyObject according to the actual GradNode structure. return py_grad_node; |
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.
GradooNodeToPyObject这个命名改成ToPyObject吧~
然后实现方法可以参考如下代码:
PyObject* ToPyObject(const platform::Place& value) {
auto obj = ::pybind11::cast(value);
obj.inc_ref();
return obj.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.
我觉得这个方案已经具备开始开发的条件了过程中遇到具体问题咱们再讨论解决
哈喽导师,想问下咱们用什么软件在什么平台下开发呀。我现在在pyharm下看代码,感觉pycham看c++代码有些不方便 |
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
我们内部大多数人用的都是VSCode。其实用什么IDE我觉得都可以,只要用着舒服。 |
赛题七:实现飞桨框架动态图反向图的可视化 设计文档