Skip to content

[CINN]Add remove_redundant_full_ops_pass #72554

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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

leon062112
Copy link
Contributor

PR Category

CINN

PR Types

Performance

Description

Pcard-67164

  1. 添加remove_redundant_full_ops_pass, 将重复出现的full_int_array以及full op移除

Pass前后IR Printing

398: ===---------------------------------------------------------------------------------===
398:         IRPrinting on builtin.module before remove_redundant_full_ops_pass pass
398: ===---------------------------------------------------------------------------------===
398: {
398:     (%0) = "pd_op.data" [id:88] () {dtype:float32,name:"var_0",place:Place(undefined:0),shape:[-1,64,-1,-1],stop_gradient:[false]} : () -> tensor<-1x64x-1x-1xf32>
398:     (%1) = "pd_op.data" [id:89] () {dtype:float32,name:"var_1",place:Place(undefined:0),shape:[-1,64,-1,-1],stop_gradient:[false]} : () -> tensor<-1x64x-1x-1xf32>
398:     (%2) = "pd_op.full" [id:90] () {dtype:float64,place:Place(cpu),shape:[1],stop_gradient:[true],value:1} : () -> tensor<1xf64>
398:     (%3) = "pd_op.full" [id:91] () {dtype:float64,place:Place(cpu),shape:[1],stop_gradient:[true],value:11} : () -> tensor<1xf64>
398:     (%4) = "pd_op.full" [id:92] () {dtype:float64,place:Place(cpu),shape:[1],stop_gradient:[true],value:1} : () -> tensor<1xf64>
398:     (%5) = "pd_op.arange" [id:93] (%2, %3, %4) {dtype:int64,place:Place(undefined:0),stop_gradient:[true]} : (tensor<1xf64>, tensor<1xf64>, tensor<1xf64>) -> tensor<10xi64>
398:     (%6, %7) = "cinn_runtime.jit_kernel" [id:165] (%5, %0) {kernel_info:(fn_scale_cast_reshape_gs_bc_gs_bc_mul_)} : (tensor<10xi64>, tensor<-1x64x-1x-1xf32>) -> tensor<10x1x1x1xf32>, tensor<10x64x-1x-1xf32>
398:     (%8) = "cinn_runtime.jit_kernel" [id:166] (%1, %6) {kernel_info:(fn_gs_bc_gs_bc_mul_)} : (tensor<-1x64x-1x-1xf32>, tensor<10x1x1x1xf32>) -> tensor<10x64x-1x-1xf32>
398:     (%9) = "cinn_runtime.jit_kernel" [id:167] (%0, %1, %7, %8) {kernel_info:(fn_gs_bc_gs_bc_add_)} : (tensor<-1x64x-1x-1xf32>, tensor<-1x64x-1x-1xf32>, tensor<10x64x-1x-1xf32>, tensor<10x64x-1x-1xf32>) -> tensor<10x64x-1x-1xf32>
398:     () = "builtin.shadow_output" [id:102] (%6) {output_name:"middle_0"} : (tensor<10x1x1x1xf32>) -> 
398:     () = "builtin.shadow_output" [id:103] (%7) {output_name:"middle_1"} : (tensor<10x64x-1x-1xf32>) -> 
398:     () = "builtin.shadow_output" [id:104] (%8) {output_name:"middle_2"} : (tensor<10x64x-1x-1xf32>) -> 
398:     () = "builtin.shadow_output" [id:105] (%9) {output_name:"output_0"} : (tensor<10x64x-1x-1xf32>) -> 
398: }
398: ===--------------------------------------------------------------------------------===
398:         IRPrinting on builtin.module after remove_redundant_full_ops_pass pass
398: ===--------------------------------------------------------------------------------===
398: {
398:     (%0) = "pd_op.data" [id:88] () {dtype:float32,name:"var_0",place:Place(undefined:0),shape:[-1,64,-1,-1],stop_gradient:[false]} : () -> tensor<-1x64x-1x-1xf32>
398:     (%1) = "pd_op.data" [id:89] () {dtype:float32,name:"var_1",place:Place(undefined:0),shape:[-1,64,-1,-1],stop_gradient:[false]} : () -> tensor<-1x64x-1x-1xf32>
398:     (%2) = "pd_op.full" [id:90] () {dtype:float64,place:Place(cpu),shape:[1],stop_gradient:[true],value:1} : () -> tensor<1xf64>
398:     (%3) = "pd_op.full" [id:91] () {dtype:float64,place:Place(cpu),shape:[1],stop_gradient:[true],value:11} : () -> tensor<1xf64>
398:     (%4) = "pd_op.arange" [id:93] (%2, %3, %2) {dtype:int64,place:Place(undefined:0),stop_gradient:[true]} : (tensor<1xf64>, tensor<1xf64>, tensor<1xf64>) -> tensor<10xi64>
398:     (%5, %6) = "cinn_runtime.jit_kernel" [id:165] (%4, %0) {kernel_info:(fn_scale_cast_reshape_gs_bc_gs_bc_mul_)} : (tensor<10xi64>, tensor<-1x64x-1x-1xf32>) -> tensor<10x1x1x1xf32>, tensor<10x64x-1x-1xf32>
398:     (%7) = "cinn_runtime.jit_kernel" [id:166] (%1, %5) {kernel_info:(fn_gs_bc_gs_bc_mul_)} : (tensor<-1x64x-1x-1xf32>, tensor<10x1x1x1xf32>) -> tensor<10x64x-1x-1xf32>
398:     (%8) = "cinn_runtime.jit_kernel" [id:167] (%0, %1, %6, %7) {kernel_info:(fn_gs_bc_gs_bc_add_)} : (tensor<-1x64x-1x-1xf32>, tensor<-1x64x-1x-1xf32>, tensor<10x64x-1x-1xf32>, tensor<10x64x-1x-1xf32>) -> tensor<10x64x-1x-1xf32>
398:     () = "builtin.shadow_output" [id:102] (%5) {output_name:"middle_0"} : (tensor<10x1x1x1xf32>) -> 
398:     () = "builtin.shadow_output" [id:103] (%6) {output_name:"middle_1"} : (tensor<10x64x-1x-1xf32>) -> 
398:     () = "builtin.shadow_output" [id:104] (%7) {output_name:"middle_2"} : (tensor<10x64x-1x-1xf32>) -> 
398:     () = "builtin.shadow_output" [id:105] (%8) {output_name:"output_0"} : (tensor<10x64x-1x-1xf32>) -> 
398: }

Copy link

paddle-bot bot commented Apr 29, 2025

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

@paddle-bot paddle-bot bot added the contributor External developers label Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant