Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
43d6bdca
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
43d6bdca
编写于
5月 25, 2023
作者:
R
ronnywang
提交者:
GitHub
5月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the custom pass with empty type (#54065)
上级
23baa8c6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
10 deletion
+38
-10
paddle/fluid/framework/ir/generate_pass.cc
paddle/fluid/framework/ir/generate_pass.cc
+6
-2
paddle/fluid/framework/ir/generate_pass.h
paddle/fluid/framework/ir/generate_pass.h
+4
-2
paddle/fluid/framework/ir/pass.h
paddle/fluid/framework/ir/pass.h
+3
-2
paddle/fluid/operators/custom_device_common_op_registry.cc
paddle/fluid/operators/custom_device_common_op_registry.cc
+23
-2
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+2
-2
未找到文件。
paddle/fluid/framework/ir/generate_pass.cc
浏览文件 @
43d6bdca
...
@@ -420,13 +420,17 @@ GraphPatternDetector::handle_t GetGenerateRewrite(
...
@@ -420,13 +420,17 @@ GraphPatternDetector::handle_t GetGenerateRewrite(
return
handler
;
return
handler
;
}
}
GeneratePass
::
GeneratePass
(
const
std
::
string
&
binary_str
)
{
GeneratePass
::
GeneratePass
(
const
std
::
string
&
binary_str
,
const
std
::
string
&
pass_type
)
{
RegisterType
(
pass_type
);
multi_pass_desc_
.
ParseFromString
(
binary_str
);
multi_pass_desc_
.
ParseFromString
(
binary_str
);
VerifyDesc
();
VerifyDesc
();
}
}
GeneratePass
::
GeneratePass
(
const
proto
::
MultiPassDesc
&
multi_pass_desc
)
GeneratePass
::
GeneratePass
(
const
proto
::
MultiPassDesc
&
multi_pass_desc
,
const
std
::
string
&
pass_type
)
:
multi_pass_desc_
(
multi_pass_desc
)
{
:
multi_pass_desc_
(
multi_pass_desc
)
{
RegisterType
(
pass_type
);
VerifyDesc
();
VerifyDesc
();
}
}
...
...
paddle/fluid/framework/ir/generate_pass.h
浏览文件 @
43d6bdca
...
@@ -24,9 +24,11 @@ namespace ir {
...
@@ -24,9 +24,11 @@ namespace ir {
class
GeneratePass
:
public
Pass
{
class
GeneratePass
:
public
Pass
{
public:
public:
// from binary_str
// from binary_str
explicit
GeneratePass
(
const
std
::
string
&
binary_str
);
explicit
GeneratePass
(
const
std
::
string
&
binary_str
,
const
std
::
string
&
pass_type
=
""
);
// from PassDesc/MultiPassDesc
// from PassDesc/MultiPassDesc
explicit
GeneratePass
(
const
proto
::
MultiPassDesc
&
multi_pass_desc
);
explicit
GeneratePass
(
const
proto
::
MultiPassDesc
&
multi_pass_desc
,
const
std
::
string
&
pass_type
=
""
);
protected:
protected:
void
ApplyImpl
(
Graph
*
graph
)
const
override
;
void
ApplyImpl
(
Graph
*
graph
)
const
override
;
...
...
paddle/fluid/framework/ir/pass.h
浏览文件 @
43d6bdca
...
@@ -185,6 +185,9 @@ class Pass {
...
@@ -185,6 +185,9 @@ class Pass {
// Pass must be placed after this Pass.
// Pass must be placed after this Pass.
virtual
void
CheckPrevPass
()
const
{}
virtual
void
CheckPrevPass
()
const
{}
protected:
void
RegisterType
(
const
std
::
string
&
type
)
{
type_
=
type
;
}
private:
private:
template
<
typename
PassType
>
template
<
typename
PassType
>
friend
struct
PassRegistrar
;
friend
struct
PassRegistrar
;
...
@@ -207,8 +210,6 @@ class Pass {
...
@@ -207,8 +210,6 @@ class Pass {
attrs_
.
insert
(
default_attr_values
.
begin
(),
default_attr_values
.
end
());
attrs_
.
insert
(
default_attr_values
.
begin
(),
default_attr_values
.
end
());
}
}
void
RegisterType
(
const
std
::
string
&
type
)
{
type_
=
type
;
}
mutable
bool
applied_
{
false
};
mutable
bool
applied_
{
false
};
std
::
string
type_
;
std
::
string
type_
;
std
::
unordered_set
<
std
::
string
>
required_pass_attrs_
;
std
::
unordered_set
<
std
::
string
>
required_pass_attrs_
;
...
...
paddle/fluid/operators/custom_device_common_op_registry.cc
浏览文件 @
43d6bdca
...
@@ -60,6 +60,8 @@ class CConcatOpCustomDeviceKernel : public framework::OpKernel<T> {
...
@@ -60,6 +60,8 @@ class CConcatOpCustomDeviceKernel : public framework::OpKernel<T> {
int
nranks
=
ctx
.
Attr
<
int
>
(
"nranks"
);
int
nranks
=
ctx
.
Attr
<
int
>
(
"nranks"
);
int
rank
=
ctx
.
Attr
<
int
>
(
"rank"
);
int
rank
=
ctx
.
Attr
<
int
>
(
"rank"
);
int
rid
=
ctx
.
Attr
<
int
>
(
"ring_id"
);
int
rid
=
ctx
.
Attr
<
int
>
(
"ring_id"
);
auto
place
=
ctx
.
GetPlace
();
PADDLE_ENFORCE_GE
(
rank
,
PADDLE_ENFORCE_GE
(
rank
,
0
,
0
,
platform
::
errors
::
PreconditionNotMet
(
platform
::
errors
::
PreconditionNotMet
(
...
@@ -98,8 +100,27 @@ class CConcatOpCustomDeviceKernel : public framework::OpKernel<T> {
...
@@ -98,8 +100,27 @@ class CConcatOpCustomDeviceKernel : public framework::OpKernel<T> {
auto
task
=
pg
->
AllGather
(
in_tensor
,
out_tensor
);
auto
task
=
pg
->
AllGather
(
in_tensor
,
out_tensor
);
task
->
Wait
();
task
->
Wait
();
}
else
{
}
else
{
PADDLE_THROW
(
phi
::
errors
::
Unavailable
(
auto
comm
=
platform
::
XCCLCommContext
::
Instance
(
place
.
GetDeviceType
())
"CustomDevice c_concat only support ProcessGroup"
));
.
Get
(
rid
,
place
);
PADDLE_ENFORCE_EQ
(
nranks
,
comm
->
nranks
(),
platform
::
errors
::
InvalidArgument
(
"nranks: %s should equal to %s"
,
nranks
,
comm
->
nranks
()));
int64_t
send_numel
=
x
->
numel
();
const
T
*
send_buff
=
x
->
data
<
T
>
();
T
*
recv_buff
=
temp_out
.
data
<
T
>
();
// should ExecutionContext for calc stream.
auto
&
stream
=
*
dev_ctx
.
GetStream
();
phi
::
DeviceManager
::
CCLAllGather
(
place
.
GetDeviceType
(),
reinterpret_cast
<
void
*>
(
const_cast
<
T
*>
(
send_buff
)),
recv_buff
,
send_numel
,
phi
::
ccl
::
ToCCLDataType
(
x
->
dtype
()),
comm
->
comm
(),
stream
);
}
}
std
::
vector
<
phi
::
DenseTensor
>
inputs
;
std
::
vector
<
phi
::
DenseTensor
>
inputs
;
int
axis
=
x
->
dims
().
size
()
-
1
;
int
axis
=
x
->
dims
().
size
()
-
1
;
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
43d6bdca
...
@@ -2275,8 +2275,8 @@ All parameter, weight, gradient are variables in Paddle.
...
@@ -2275,8 +2275,8 @@ All parameter, weight, gradient are variables in Paddle.
pass_type
,
[
pass_type
,
callable
]()
{
pass_type
,
[
pass_type
,
callable
]()
{
py
::
gil_scoped_acquire
guard
;
py
::
gil_scoped_acquire
guard
;
std
::
unique_ptr
<
framework
::
ir
::
Pass
>
pass
(
std
::
unique_ptr
<
framework
::
ir
::
Pass
>
pass
(
new
framework
::
ir
::
GeneratePass
(
new
framework
::
ir
::
GeneratePass
(
py
::
cast
<
std
::
string
>
(
callable
()),
py
::
cast
<
std
::
string
>
(
callable
())
));
pass_type
));
return
pass
;
return
pass
;
});
});
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录