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

[IR] OpTrait & OpInterface & OpInfo #52846

Merged
merged 36 commits into from
May 6, 2023

Conversation

zhangbo9674
Copy link
Contributor

@zhangbo9674 zhangbo9674 commented Apr 12, 2023

PR types

New features

PR changes

Others

Description

本 PR 包括 Paddle 新 IR 的:OpTrait、OpInterface、OpInfo

1. 主要内容

  • OpInfo / OpInfoImpl
    • 类型信息指:对于同类型算子而言,完全一致的信息。 这类信息应该是只读的,生命周期要不依赖具体算子的创建or销毁。因此,由 IrContext 负责 OpInfoImpl 的创建和回收,算子自身只需在构造时,接受 OpInfo(OpInfoImpl指针)作为参数即可。
    • OpInfoImpl包含的信息有:Traits、Interfaces、Attributes_name、op_name,为了节省内存,采用与 Operation 相似的策略:统一分配一段连续内存,在该内存上一次构造 interfaces、traits、opinfo_impl.

2. 各数据结构关系

图片

Other

Pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented Apr 12, 2023

你的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.

@@ -60,9 +60,9 @@ DictionaryAttributeStorage::ParamKey DictionaryAttributeStorage::GetAsKey()

Attribute DictionaryAttributeStorage::GetValue(const StrAttribute &name) const {
if (size_ > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这儿的二分是不是可以直接 left = 0, right = size, 没必要判断size>0啊?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, tks!

/// interface functions, and Model is a template class that defines the specific
/// implementation of interface functions based on template parameters.
///
class InferShapeInterface : public OpInterfaceBase<InferShapeInterface> {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个InferShapeInterface需要想办法跟paddle里面的phi里面的infershpe关联起来。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的,该内容已记录 Todo,Program 表示阶段进行开发。

registed_operations_.emplace(type_id, opinfo);
}

OpInfoImpl *GetOperation(ir::TypeId type_id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个函数名是不是改成GetOpInfo更合适一点?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, ths!

template <typename T>
static void PlacementConstrctInterface(
std::pair<TypeId, void *> *&p_interface) { // NOLINT
void *ptmp = malloc(sizeof(typename T::template Model<ConcreteOp>));
Copy link
Contributor

Choose a reason for hiding this comment

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

这儿为啥不直接p_interface->second = malloc(.......)呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的,已完善实现方法。

winter-wang
winter-wang previously approved these changes Apr 25, 2023
Copy link
Contributor

@winter-wang winter-wang left a comment

Choose a reason for hiding this comment

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

LGTM

winter-wang
winter-wang previously approved these changes Apr 25, 2023
Copy link
Contributor

@winter-wang winter-wang left a comment

Choose a reason for hiding this comment

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

LGTM

Shixiaowei02
Shixiaowei02 previously approved these changes Apr 25, 2023
@zhangbo9674 zhangbo9674 dismissed stale reviews from Shixiaowei02 and winter-wang via 4464df4 April 26, 2023 08:19
Copy link
Contributor

@winter-wang winter-wang left a comment

Choose a reason for hiding this comment

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

LGTM

@paddle-ci-bot
Copy link

paddle-ci-bot bot commented May 4, 2023

Sorry to inform you that 4464df4's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

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

LGTM

@zhangbo9674 zhangbo9674 merged commit d91d758 into PaddlePaddle:develop May 6, 2023
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.

4 participants