Skip to content
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

Merged
merged 3 commits into from
May 30, 2023

Conversation

qiuwenbogdut
Copy link
Contributor

@paddle-bot
Copy link

paddle-bot bot commented May 10, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请检查PR提交格式和内容是否完备,具体请参考示例模版
Your PR has been submitted. Thanks for your contribution!
Please check its format and content. For this, you can refer to Template and Demo.

@ZS-YANG
Copy link

ZS-YANG commented May 21, 2023

哈喽 请问这个项目你们完成的进度怎么样了,队里几个人呀

@qiuwenbogdut
Copy link
Contributor Author

哈喽 请问这个项目你们完成的进度怎么样了,队里几个人呀

进度是目前只写了一个RFC文档, 导师还没有进行审核.
目前队里只有一个人,

目前项目进展有个难点, 对于paddle中python调用c++的流程细节还没有梳理清楚, 目前还不能进行调试

Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

设计文档还需要细化:

  1. 获取paddle的反向图的节点信息
  2. 将反向图的节点信息暴露给pythonAPI
    这两点是本项目的难点:
  3. tensor.grad_fn 应该在paddle/fluid/pybind/eager_properties.cc中实现。可以通过:
    auto meta = egr::EagerUtils::nullable_autograd_meta(self->tensor);
    meta.GradNode()
    获取到GradNode
  4. 需要参考paddle/fluid/pybind/eager.cc中的BindEager函数。将GradNode作为一个类型暴露给Python。BindEager通过调用PyModule_AddObject将Tensor暴露给了Python。你可以参考一下。
  5. next_functions是GradNode暴露到Python端的类型的一个属性。需要参考paddle/fluid/pybind/eager_properties.cc实现。eager_properties.cc里是将Tensor的属性暴露的具体实现源码。
  6. 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();
    }
    }
    实现。

@ZS-YANG
Copy link

ZS-YANG commented May 22, 2023

哈喽 请问这个项目你们完成的进度怎么样了,队里几个人呀

进度是目前只写了一个RFC文档, 导师还没有进行审核. 目前队里只有一个人,

目前项目进展有个难点, 对于paddle中python调用c++的流程细节还没有梳理清楚, 目前还不能进行调试

python调用c++的流程是不是可以通过开发成c++算子实现?

@qiuwenbogdut
Copy link
Contributor Author

哈喽 请问这个项目你们完成的进度怎么样了,队里几个人呀

进度是目前只写了一个RFC文档, 导师还没有进行审核. 目前队里只有一个人,
目前项目进展有个难点, 对于paddle中python调用c++的流程细节还没有梳理清楚, 目前还不能进行调试

python调用c++的流程是不是可以通过开发成c++算子实现?

流程应该是一致的, 将c++实现的函数 暴露出来给到python进行调用.

@luotao1
Copy link
Collaborator

luotao1 commented May 23, 2023

@ZS-YANG 如果有兴趣参加,可以联系运营加群
image

Copy link
Contributor

@wanghuancoder wanghuancoder left a 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;
Copy link
Contributor

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();
}

Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

我觉得这个方案已经具备开始开发的条件了过程中遇到具体问题咱们再讨论解决

@ZS-YANG
Copy link

ZS-YANG commented May 29, 2023

我觉得这个方案已经具备开始开发的条件了过程中遇到具体问题咱们再讨论解决

哈喽导师,想问下咱们用什么软件在什么平台下开发呀。我现在在pyharm下看代码,感觉pycham看c++代码有些不方便

Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1 luotao1 merged commit 511203c into PaddlePaddle:master May 30, 2023
@wanghuancoder
Copy link
Contributor

我觉得这个方案已经具备开始开发的条件了过程中遇到具体问题咱们再讨论解决

哈喽导师,想问下咱们用什么软件在什么平台下开发呀。我现在在pyharm下看代码,感觉pycham看c++代码有些不方便

我们内部大多数人用的都是VSCode。其实用什么IDE我觉得都可以,只要用着舒服。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants