Skip to content

[AP] Implement pcc compile engine frontend of trivial fusion. #72640

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

Merged
merged 53 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0ec2dec
abstract pass initial commit
lixinqi Feb 13, 2025
df6414a
Merge branch 'develop' of github.com:lixinqi/Paddle into ap
lixinqi Feb 13, 2025
96fea1c
remove unused index_expr code
lixinqi Feb 13, 2025
f15a766
Fix compiling error on CI.
Xreki Feb 17, 2025
aaeed58
Merge branch 'ap' of https://github.com/lixinqi/Paddle into ap
Xreki Feb 19, 2025
35196b4
Change the log level.
Xreki Feb 19, 2025
639a8b3
Rename ap_lower_fusion_op_pass to ap_generic_drr_pass.
Xreki Feb 19, 2025
1e0a138
Rename ap_unary -> ap_variadic, ApUnary -> ApVariadic.
Xreki Feb 19, 2025
01e2686
Fallback to cinn when ap fails, and disable fuse_gemm_epilogue when a…
Xreki Feb 20, 2025
34d490a
Fix compiling error in CI, including: using std::memcpy instead of re…
Xreki Feb 20, 2025
4832e4c
Fix narrowing conversion error and unused value error.
Xreki Feb 21, 2025
4db56bc
Fix missing-field-initializers and unused-result error on CI.
Xreki Feb 21, 2025
a441f80
Fix some sign-compare error on CI.
Xreki Feb 21, 2025
60676fe
Add cmake dependent.
Xreki Feb 25, 2025
6b786d9
Fix some using statement without creating an alias.
Xreki Feb 25, 2025
f36dfe8
Support experimental/type_traits for WIN32.
Xreki Feb 25, 2025
b950804
Fix an unused-but-set-parameter and remove the `typename` in using st…
Xreki Feb 26, 2025
5f6e67a
Disable AP when cinn is not enabled.
Xreki Feb 26, 2025
6b7446c
Merge branch 'develop' into ap
Xreki Mar 20, 2025
4691ca4
Remove the use of Reciprocal because Reciprocal is deleted by #70376.
Xreki Mar 20, 2025
a8e051d
Merge branch 'develop' into ap
Xreki Mar 21, 2025
b031281
Fix "basic_string::_M_construct null not valid" error.
Xreki Mar 21, 2025
ba5c576
Fix typo.
Xreki Mar 21, 2025
9f3b79c
Support meticulous matching (with input/outoput number). Submit by hx…
Xreki Mar 21, 2025
6408d08
remove redundant sentence
hxzd5568 Apr 1, 2025
d058177
Using void* as StreamT.
Xreki Apr 2, 2025
0629cb4
Fix compiling error related to std::optional<StreamT> on gcc12.
Xreki Apr 7, 2025
1119b12
Merge branch 'develop' into ap
Xreki Apr 7, 2025
2255c2f
support no-extra-use for temporary ir value in source pattern
lixinqi Apr 10, 2025
2def5b4
minor fix
lixinqi Apr 10, 2025
2e2b230
minor fix
lixinqi Apr 11, 2025
2598a93
Return the address of stream instead.
Xreki Apr 14, 2025
be2389b
support paddle.cc.*
lixinqi Apr 16, 2025
407122e
fix adt::WeakPtrLock bug
lixinqi Apr 18, 2025
b8afbfe
Merge branch 'ap' of github.com:lixinqi/Paddle into ap
lixinqi Apr 18, 2025
4beae5c
rename all non python standard api's to __builtin__xxx
lixinqi Apr 18, 2025
e457617
Merge branch 'ap' into pcc
lixinqi Apr 18, 2025
8ffef38
move paddle.cc into paddle.incubate.cc
lixinqi Apr 18, 2025
3ebbd5b
Add pcc to setup.py.
Xreki Apr 21, 2025
b0b377d
Add missing modules and return partial_program_layer directly in pcc.…
Xreki Apr 21, 2025
07e0652
Fix the mismatched output numerical order issue
hxzd5568 Apr 21, 2025
9ddfcef
Merge pull request #3 from hxzd5568/order
lixinqi Apr 21, 2025
f5e47cb
Remove force_register_fusion related codes in pcc api.
Xreki Apr 21, 2025
07f7034
Add an argument train.
Xreki Apr 21, 2025
0d357f9
support ap.facade and infer_symbolic/infer_meta in python
lixinqi Apr 25, 2025
a9354f0
merge develop
lixinqi Apr 25, 2025
2abc1ee
minor fix
lixinqi Apr 25, 2025
b9356ff
paddle.cc.ap.FacadeOp
lixinqi Apr 27, 2025
6b9a7c8
support zero inputs for pd_op.ap_facade
lixinqi Apr 28, 2025
cc4216e
1) add PCC compile engine; 2) add pcc.fuse.by_register() with-block api
lixinqi Apr 29, 2025
dee0925
merge develop
lixinqi May 9, 2025
abdfd76
Fix compiling error when cinn is not enabled.
Xreki May 9, 2025
3b0c1d6
Polish copyright and error messages.
Xreki May 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions paddle/ap/include/paddle/pass/add_pcc_pass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <functional>
#include <memory>

namespace pir {

class PassManager;
class Program;

} // namespace pir

namespace ap::paddle {

void ApplyPccPass(
::pir::Program* program,
const std::function<std::shared_ptr<pir::PassManager>()>& CreatePassManager,
bool is_train_mode = false);

} // namespace ap::paddle
4 changes: 2 additions & 2 deletions paddle/ap/include/paddle/pass/ap_drr_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "paddle/ap/include/drr/value.h"
#include "paddle/ap/include/registry/abstract_drr_pass_registry_item.h"

namespace cinn::dialect::ir {
namespace ap::paddle {

struct ApDrrHelper {
public:
Expand Down Expand Up @@ -53,4 +53,4 @@ struct ApDrrHelper {
mutable ap::drr::DrrInterpreter drr_interpreter_;
};

} // namespace cinn::dialect::ir
} // namespace ap::paddle
8 changes: 2 additions & 6 deletions paddle/ap/include/paddle/pass/ap_generic_drr_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ struct Value;

}

namespace cinn {
namespace dialect {
namespace ir {
namespace ap::paddle {

std::optional<std::unique_ptr<::pir::Pass>> CreateApGenericAbstractDrrPass(
const std::weak_ptr<ap::memory::CirclableRefListBase>& circlable_ref_list);
Expand All @@ -50,6 +48,4 @@ std::optional<std::unique_ptr<::pir::Pass>> CreateCustomAccessTopoDrrPass(
std::optional<int64_t> steps_limit,
const ap::axpr::Value& mut_matched_pattern_as_programs);

} // namespace ir
} // namespace dialect
} // namespace cinn
} // namespace ap::paddle
4 changes: 2 additions & 2 deletions paddle/ap/include/paddle/pass/ap_kernel_define_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "paddle/ap/include/code_module/code_module.h"
#include "paddle/ap/include/paddle/pir_node.h"

namespace cinn::dialect::ir {
namespace ap::paddle {

struct ApKernelDefineHelper {
std::weak_ptr<ap::memory::CirclableRefListBase> circlable_ref_list_;
Expand All @@ -41,4 +41,4 @@ struct ApKernelDefineHelper {
const CodeGenCtx& code_gen_ctx);
};

} // namespace cinn::dialect::ir
} // namespace ap::paddle
4 changes: 2 additions & 2 deletions paddle/ap/include/paddle/pass/ap_registry_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#include "paddle/ap/include/adt/adt.h"
#include "paddle/ap/include/registry/registry.h"

namespace cinn::dialect::ir {
namespace ap::paddle {

struct ApRegistryHelper {
ap::adt::Result<ap::registry::Registry> SingletonRegistry();
};

} // namespace cinn::dialect::ir
} // namespace ap::paddle
10 changes: 4 additions & 6 deletions paddle/ap/include/paddle/pass/convert_pd_facade_to_ap_facade.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ struct Value;

}

namespace cinn {
namespace dialect {
namespace ir {
namespace ap {
namespace paddle {

std::unique_ptr<::pir::Pass> CreateConvertPdFacadeToApFacadePass();

} // namespace ir
} // namespace dialect
} // namespace cinn
} // namespace paddle
} // namespace ap
41 changes: 41 additions & 0 deletions paddle/ap/include/paddle/pass/fallback_fusion_op_to_phi_pass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <memory>
#include <optional>
#include "paddle/pir/include/pass/pass.h"

namespace ap::memory {

class CirclableRefListBase;

}

namespace ap::axpr {

struct Value;

}

namespace ap {
namespace paddle {

std::unique_ptr<::pir::Pass> CreateFallbackFusionOpToPhiPass();

std::unique_ptr<::pir::Pass> CreateFallbackNestedFusionOpToPhiPass();

} // namespace paddle
} // namespace ap
39 changes: 39 additions & 0 deletions paddle/ap/include/paddle/pass/fuse_ap_trivial_pass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <memory>
#include <optional>
#include "paddle/pir/include/pass/pass.h"

namespace ap::memory {

class CirclableRefListBase;

}

namespace ap::axpr {

struct Value;

}

namespace ap {
namespace paddle {

std::unique_ptr<::pir::Pass> CreateFuseApTrivialPass();

} // namespace paddle
} // namespace ap
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <memory>
#include <optional>
#include "paddle/pir/include/pass/pass.h"

namespace ap::memory {

class CirclableRefListBase;

}

namespace ap::axpr {

struct Value;

}

namespace ap {
namespace paddle {

std::unique_ptr<::pir::Pass> CreateMoveTrivialFusionRangeToFusionOpPass();

} // namespace paddle
} // namespace ap
Loading
Loading