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

[PIR] Add Common Subexpression Elimination pass #63960

Merged
merged 30 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
61f2d56
[PIR] Add Common Subexpression Elimination pass
SigureMo Apr 28, 2024
532d242
refine
SigureMo Apr 28, 2024
625a51a
deal todos
SigureMo Apr 29, 2024
6c2a317
fix cache;
SigureMo Apr 29, 2024
923c969
update year
SigureMo Apr 29, 2024
324da43
Merge branch 'develop' into pir/add-cse-pass
SigureMo Apr 29, 2024
f88fb95
missing string include
SigureMo Apr 29, 2024
d502d4c
fix create assign
SigureMo Apr 29, 2024
14ad4ff
auto inherit expressions by make a clone
SigureMo Apr 29, 2024
8e772c9
terminate value should also check inplace
SigureMo Apr 29, 2024
91ab1a5
show cse number in log
SigureMo Apr 29, 2024
c3820a1
fix slice_array attributes_num
SigureMo Apr 30, 2024
baac9c2
update IsTerminateOp
SigureMo Apr 30, 2024
f8f5951
tmp revert baac9c2e975338a47c59878fd42b231e431bf903
SigureMo May 5, 2024
bbdd5ca
Merge branch 'develop' into pir/add-cse-pass
SigureMo May 6, 2024
009eabd
support more ops as not terminate op
SigureMo May 9, 2024
17bb052
Merge branch 'develop' into pir/add-cse-pass
SigureMo May 9, 2024
860ec3e
add ut for cse
SigureMo May 9, 2024
6538bda
Merge branch 'develop' into pir/add-cse-pass
SigureMo May 9, 2024
a314194
add more cases and fix test_pass_manager
SigureMo May 9, 2024
9c9972a
add shadow_output and vec[Tensor] support back
SigureMo May 12, 2024
cff639c
fix clang compile error
SigureMo May 12, 2024
b43873d
use flags
SigureMo May 13, 2024
53b7eb5
fix flag declare
SigureMo May 13, 2024
499f043
use int32 for cse_count
SigureMo May 13, 2024
4f8d35f
clean logs
SigureMo May 14, 2024
ed77dae
use value.impl as value id
SigureMo May 14, 2024
0aa2820
Merge branch 'develop' into pir/add-cse-pass
SigureMo May 14, 2024
6268cbf
remove terminate_value_id_
SigureMo May 14, 2024
24470eb
add some checks and fix comments
SigureMo May 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions paddle/common/flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,31 @@ PHI_DEFINE_EXPORTED_bool(
"the symbolic inference accuracy by comparing the the value "
"shape between dynamic shape and static shape.");

/**
* Apply CSE optimize pass in Dy2St
* Name: enable_cse_in_dy2st
* Since Version: 3.0.0
* Value Range: bool, default=false
* Example:
* Note: If True, will apply CSE optimize pass in Dy2St.
*/
PHI_DEFINE_EXPORTED_bool(enable_cse_in_dy2st,
false,
"Apply CSE optimize pass in Dy2St");

/**
* Max count of eliminate redundant computation in CSE, for debug usage
* Name: cse_max_count
* Since Version: 3.0.0
* Value Range: int32, default=-1
* Example:
* Note: If -1, will not limit the max count of eliminate redundant computation.
*/
PHI_DEFINE_EXPORTED_int32(
cse_max_count,
-1,
"Max count of eliminate redundant computation in CSE, for debug usage");

PHI_DEFINE_EXPORTED_string(
mkl_dir, // NOLINT
"",
Expand Down
6 changes: 6 additions & 0 deletions paddle/fluid/pir/dialect/operator/ir/ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,7 @@
func : print_kernel
param: [in, first_n, message, summarize, print_tensor_name, print_tensor_type, print_tensor_shape, print_tensor_layout, print_tensor_lod, print_phase, is_forward]
interfaces : paddle::dialect::InferSymbolicShapeInterface
traits : pir::SideEffectTrait

- op : prod
args : (Tensor x, IntArray dims, bool keep_dim, bool reduce_all)
Expand Down Expand Up @@ -1418,6 +1419,7 @@
data_type : dtype
backend : place
interfaces : paddle::dialect::InferSymbolicShapeInterface
traits : pir::SideEffectTrait

- op : randperm
args : (int n, DataType dtype, Place place={})
Expand All @@ -1430,6 +1432,7 @@
param : [n, dtype]
data_type : dtype
backend : place
traits : pir::SideEffectTrait

- op : rank_attention
args : (Tensor x, Tensor rank_offset, Tensor rank_param, int max_rank = 3, int max_size = 0)
Expand Down Expand Up @@ -1860,6 +1863,7 @@
param : [shape, mean, std, seed, dtype]
backend : place
data_type : dtype
traits : pir::SideEffectTrait

- op : uniform
args : (IntArray shape, DataType dtype, Scalar min, Scalar max, int seed, Place place={})
Expand All @@ -1873,6 +1877,7 @@
data_type : dtype
backend : place
interfaces : paddle::dialect::InferSymbolicShapeInterface
traits : pir::SideEffectTrait

- op : uniform_random_batch_size_like
args : (Tensor input, int[] shape, int input_dim_idx=0, int output_dim_idx=0, float min=-1.0f, float max=1.0f, int seed=0, int diag_num=0, int diag_step=0, float diag_val=1.0f, DataType dtype=DataType::FLOAT32)
Expand All @@ -1883,6 +1888,7 @@
kernel :
func : uniform_random_batch_size_like
data_type : dtype
traits : pir::SideEffectTrait

- op : unique
args : (Tensor x, bool return_index=false, bool return_inverse=false, bool return_counts=false, int[] axis={}, DataType dtype=DataType::INT64, bool is_sorted=false)
Expand Down