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

[JitLayer]Split layer_utils.cc and polish interface BaseFunction #43754

Merged
merged 6 commits into from
Jun 23, 2022

Conversation

0x45f
Copy link
Contributor

@0x45f 0x45f commented Jun 22, 2022

PR types

Others

PR changes

Others

Describe

[JitLayer]Split layer_utils.cc and polish interface BaseFunction

  1. 将BaseFunction抽象为一个接口类,只进行公共接口的定义。将公共的方法放到了layer_utils中。
  2. 添加了FunctionInfo类,FunctionInfo持有了Funcion相关的信息:func_name、param_names_、program_desc_、schema_。每个Funtion都会持有一个FunctionInfo的对象,后面可以考虑将FunctionInfo和FunctionSchema合并为一个类。抽离出FunctionInfo类后Layer、Function的构造时只需要对应的FunctionInfo对象即可,减少了构造函数的参数个数,同时schema和program_desc的处理可以都放到FunctionInfo的构造函数中,Funtion的构造函数更加简单。
  3. Layer类中添加了params_dict和attrs_dict来管理params和attrs的生命周期。
  4. 引入compilation_unit,Layer持有一个CompilationUnit来对Function进行管理
  5. 移除了一些不必要的头文件,修改了部分函数的参数类型,重命名了某些变量

@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.

return schema_.GetInputArgNames();
}

const std::vector<std::string> FunctionInfo::GetOutputArgNames() const {
Copy link
Contributor

Choose a reason for hiding this comment

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

后续我们可以把Get前缀去掉,因为API名字太长了

#include "paddle/fluid/framework/program_desc.h"
#include "paddle/phi/core/enforce.h"

#include "paddle/fluid/jit/layer_utils.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

这里应该不需要依赖layer_utils.h 头文件?

function_dict[func_names[i]] = std::make_shared<ExectorFunction>(
program_descs[i], param_names_for_each_program[i], params_dict, place);
function_dict_[infos[i]->GetFunctionName()] =
std::make_shared<ExectorFunction>(infos[i], params_dict_, place);
Copy link
Contributor

Choose a reason for hiding this comment

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

这里我们是默认创建了ExecutorFuntion,后续统一到CompilationUnit后,我们可以Lazy模式创建这些执行引擎

Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

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

LGTM

@0x45f 0x45f merged commit 3be36a8 into PaddlePaddle:develop Jun 23, 2022
@0x45f 0x45f deleted the polish-multi-program branch June 23, 2022 09:47
sneaxiy pushed a commit to sneaxiy/Paddle that referenced this pull request Jun 27, 2022
…dlePaddle#43754)

* Split layer_utils.cc and polish interface BaseFunction

* Polish include

* Fix cmake for funciton_schema

* Using unordered_map replace map and rename VariableNameMap

* Polish Layer Constructor and remove useless include

* Refine compilation_unit
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.

2 participants