Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d12b1ffa
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
d12b1ffa
编写于
4月 12, 2023
作者:
Y
Yuanle Liu
提交者:
GitHub
4月 12, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move delete_cast_op_pass (#52788)
上级
b835d958
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
31 addition
and
30 deletion
+31
-30
paddle/fluid/framework/ir/CMakeLists.txt
paddle/fluid/framework/ir/CMakeLists.txt
+6
-5
paddle/fluid/framework/ir/delete_cast_op_pass.cc
paddle/fluid/framework/ir/delete_cast_op_pass.cc
+24
-25
paddle/fluid/framework/ir/delete_cast_op_pass.h
paddle/fluid/framework/ir/delete_cast_op_pass.h
+0
-0
paddle/fluid/framework/ir/delete_cast_op_pass_test.cc
paddle/fluid/framework/ir/delete_cast_op_pass_test.cc
+0
-0
paddle/fluid/inference/api/paddle_pass_builder.cc
paddle/fluid/inference/api/paddle_pass_builder.cc
+1
-0
未找到文件。
paddle/fluid/framework/ir/CMakeLists.txt
浏览文件 @
d12b1ffa
...
...
@@ -126,6 +126,7 @@ pass_library(matmul_scale_fuse_pass inference)
pass_library
(
gpu_cpu_map_matmul_to_mul_pass inference
)
pass_library
(
dense_fc_to_sparse_pass inference
)
pass_library
(
dense_multihead_matmul_to_sparse_pass inference
)
pass_library
(
delete_cast_op_pass inference
)
pass_library
(
generate_pass DEPS pass_desc_proto
)
target_link_libraries
(
generate_pass pass_desc_proto
)
...
...
@@ -242,7 +243,6 @@ if(WITH_XPU)
pass_library
(
fused_multi_transformer_xpu_quant_pass inference DIR xpu DEPS
${
XPU_PASS_DEPS
}
)
pass_library
(
stack_fuse_pass inference DIR xpu DEPS
${
XPU_PASS_DEPS
}
)
pass_library
(
delete_cast_op_pass inference DIR xpu DEPS
${
XPU_PASS_DEPS
}
)
endif
()
cc_library
(
...
...
@@ -407,6 +407,11 @@ cc_test(
test_delete_dequant_weight_linear_op_pass
SRCS delete_weight_dequant_linear_op_pass_tester.cc
DEPS delete_weight_dequant_linear_op_pass
)
cc_test
(
test_delete_cast_op_pass
SRCS delete_cast_op_pass_test.cc
DEPS delete_cast_op_pass
)
if
(
WITH_GPU OR WITH_ROCM
)
cc_test
(
test_embedding_eltwise_layernorm_fuse_pass
...
...
@@ -521,8 +526,4 @@ if(WITH_XPU)
test_stack_fuse_pass
SRCS xpu/stack_fuse_pass_test.cc
DEPS stack_fuse_pass
)
cc_test
(
test_delete_cast_op_pass
SRCS xpu/delete_cast_op_pass_test.cc
DEPS delete_cast_op_pass
)
endif
()
paddle/fluid/framework/ir/
xpu/
delete_cast_op_pass.cc
→
paddle/fluid/framework/ir/delete_cast_op_pass.cc
浏览文件 @
d12b1ffa
...
...
@@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/framework/ir/
xpu/
delete_cast_op_pass.h"
#include <string>
#include "paddle/fluid/framework/ir/delete_cast_op_pass.h"
#include "paddle/fluid/framework/ir/graph_pattern_detector.h"
#include "paddle/fluid/framework/ir/xpu/pass_utils.h"
#include "paddle/fluid/framework/op_version_registry.h"
#include "paddle/fluid/platform/enforce.h"
...
...
@@ -127,11 +126,11 @@ int DeleteCastOpPass::ApplyCastWriteReadPass(ir::Graph* graph) const {
auto
handler
=
[
&
](
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
Graph
*
graph
)
{
VLOG
(
4
)
<<
"handle ApplyCastWriteReadPass fuse"
;
GET_IR_NODE
(
cast0
);
GET_IR_NODE
(
write_to_array
);
GET_IR_NODE
(
cast0_i
n
);
GET_IR_NODE
(
cast0_out
);
GET_IR_NODE
(
write_to_array_out
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast0
,
cast0
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
write_to_array
,
write_to_array
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast0_in
,
cast0_in
,
patter
n
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast0_out
,
cast0_out
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
write_to_array_out
,
write_to_array_out
,
pattern
);
// write_to_array_out(in graph1) may not link to any op nodes, so we fine
// read_from_array by write_to_array_out name.
...
...
@@ -281,13 +280,13 @@ int DeleteCastOpPass::ApplyCastLodResetWriteReadPass(ir::Graph* graph) const {
auto
handler
=
[
&
](
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
Graph
*
graph
)
{
VLOG
(
4
)
<<
"handle ApplyCastLodResetWriteReadPass fuse"
;
GET_IR_NODE
(
cast0
);
GET_IR_NODE
(
lod_reset
);
GET_IR_NODE
(
write_to_array
);
GET_IR_NODE
(
cast0_i
n
);
GET_IR_NODE
(
cast0_out
);
GET_IR_NODE
(
lod_reset_out
);
GET_IR_NODE
(
write_to_array_out
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast0
,
cast0
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
lod_reset
,
lod_reset
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
write_to_array
,
write_to_array
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast0_in
,
cast0_in
,
patter
n
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast0_out
,
cast0_out
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
lod_reset_out
,
lod_reset_out
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
write_to_array_out
,
write_to_array_out
,
pattern
);
// write_to_array_out(in graph1) may not link to any op nodes, so we fine
// read_from_array by write_to_array_out name.
...
...
@@ -482,13 +481,13 @@ int DeleteCastOpPass::ApplyCastIndexSamplePass(ir::Graph* graph) const {
auto
handler
=
[
&
](
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
Graph
*
graph
)
{
VLOG
(
4
)
<<
"handle ApplyCastIndexSamplePass fuse"
;
GET_IR_NODE
(
cast0
);
GET_IR_NODE
(
index_sample
);
GET_IR_NODE
(
cast1
);
GET_IR_NODE
(
cast0_i
n
);
GET_IR_NODE
(
cast0_out
);
GET_IR_NODE
(
index_sample_out
);
GET_IR_NODE
(
cast1_out
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast0
,
cast0
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
index_sample
,
index_sample
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast1
,
cast1
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast0_in
,
cast0_in
,
patter
n
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast0_out
,
cast0_out
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
index_sample_out
,
index_sample_out
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast1_out
,
cast1_out
,
pattern
);
index_sample
->
Op
()
->
RenameInput
(
cast0_out
->
Name
(),
cast0_in
->
Name
());
index_sample
->
Op
()
->
RenameOutput
(
index_sample_out
->
Name
(),
...
...
@@ -545,9 +544,9 @@ int DeleteCastOpPass::ApplyCastPass(ir::Graph* graph) const {
auto
handler
=
[
&
](
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
Graph
*
graph
)
{
VLOG
(
4
)
<<
"handle ApplyCastPass fuse"
;
GET_IR_NODE
(
cast
);
GET_IR_NODE
(
cast_i
n
);
GET_IR_NODE
(
cast_out
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast
,
cast
,
pattern
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast_in
,
cast_in
,
patter
n
);
GET_IR_NODE
_FROM_SUBGRAPH
(
cast_out
,
cast_out
,
pattern
);
for
(
auto
*
out_op_node
:
cast_out
->
outputs
)
{
out_op_node
->
Op
()
->
RenameInput
(
cast_out
->
Name
(),
cast_in
->
Name
());
IR_NODE_LINK_TO
(
cast_in
,
out_op_node
);
...
...
paddle/fluid/framework/ir/
xpu/
delete_cast_op_pass.h
→
paddle/fluid/framework/ir/delete_cast_op_pass.h
浏览文件 @
d12b1ffa
文件已移动
paddle/fluid/framework/ir/
xpu/
delete_cast_op_pass_test.cc
→
paddle/fluid/framework/ir/delete_cast_op_pass_test.cc
浏览文件 @
d12b1ffa
文件已移动
paddle/fluid/inference/api/paddle_pass_builder.cc
浏览文件 @
d12b1ffa
...
...
@@ -276,6 +276,7 @@ GpuPassStrategy::GpuPassStrategy() : PassStrategy({}) {
"transpose_flatten_concat_fuse_pass"
,
//
"conv2d_fusion_layout_transfer_pass"
,
//
"auto_mixed_precision_pass"
,
//
"delete_cast_op_pass"
,
//
"inplace_op_var_pass"
,
// should be the last pass.
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录