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

[CINN] Removed 0d-to-1d pass #62612

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions paddle/cinn/hlir/dialect/operator/transforms/add_cinn_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "paddle/cinn/hlir/dialect/operator/transforms/dynamic_reshape_pass.h"
#include "paddle/cinn/hlir/dialect/operator/transforms/fold_manipulation_ops_pass.h"
#include "paddle/cinn/hlir/dialect/operator/transforms/fuse_shape_ops_into_generate_shape_op_pass.h"
#include "paddle/cinn/hlir/dialect/operator/transforms/group_merge/convert_0d_to_1d_pass.h"
#include "paddle/cinn/hlir/dialect/operator/transforms/group_merge/convert_dynamic_to_static_dim_pass.h"
#include "paddle/cinn/hlir/dialect/operator/transforms/group_merge/convert_static_dim_to_dynamic_pass.h"
#include "paddle/cinn/hlir/dialect/operator/transforms/group_merge/divide_group_op_to_fusion_op_pass.h"
Expand Down Expand Up @@ -94,9 +93,7 @@ void ApplyCinnPreprocessPass(
bool has_dynamic_shape = HasDynamicShape(*program);

if (has_dynamic_shape) {
pass_manager->AddPass(cinn::dialect::ir::CreateConvert0DTo1DPass());
pass_manager->AddPass(pir::CreateShapeOptimizationPass());
pass_manager->AddPass(cinn::dialect::ir::CreateConvert0DTo1DPass());
pass_manager->AddPass(
cinn::dialect::ir::CreateFuseShapeOpsIntoGenerateShapeOpPass());
pass_manager->AddPass(pir::CreateDeadCodeEliminationPass());
Expand Down

This file was deleted.

This file was deleted.

5 changes: 3 additions & 2 deletions paddle/cinn/operator_fusion/policy/relative_judge_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ static ValueDimRelation CreateOpRelativenessForReduce(pir::Operation* op) {
int out_idx = 0;
bool keep_dim = GetReduceOpKeepDims(op);
for (int i = 0; i < input_rank; i++) {
if (std::find(reduce_axis_idx.begin(), reduce_axis_idx.end(), i) !=
reduce_axis_idx.end()) {
if (!reduce_axis_idx.empty() &&
std::find(reduce_axis_idx.begin(), reduce_axis_idx.end(), i) ==
reduce_axis_idx.end()) {
res[ValueDim(op->operand_source(0), i)]
[ValueDim(op->result(0), out_idx)] = true;
out_idx += 1;
Expand Down
5 changes: 3 additions & 2 deletions paddle/cinn/operator_fusion/policy/shardable_axes_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ ShardableAxesSignature CreateSignatureForReduce(pir::Operation* reduce_op) {
auto output_axes = std::vector<std::string>();

for (int i = 0; i < input_rank; i++) {
if (std::find(reduce_axis_idx.begin(), reduce_axis_idx.end(), i) !=
reduce_axis_idx.end()) {
if (reduce_axis_idx.empty() ||
std::find(reduce_axis_idx.begin(), reduce_axis_idx.end(), i) !=
reduce_axis_idx.end()) {
if (keep_dim) {
output_axes.emplace_back(ShardableAxesInfoManager::GetUniqueName());
} // else do nothing
Expand Down
4 changes: 4 additions & 0 deletions paddle/cinn/operator_fusion/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ static std::vector<int64_t> GetReduceAxisIdx(pir::Operation* reduce_op) {
CHECK(attr_val.isa<::pir::ArrayAttribute>());
const auto& axis_attr = attr_val.dyn_cast<::pir::ArrayAttribute>();
std::vector<int64_t> reduce_axis_idx;
if (input_rank == 0) {
VLOG(4) << "Reduce op has 0D Tensor input, return empty reduce_axis";
return reduce_axis_idx;
}
for (int i = 0; i < axis_attr.size(); ++i) {
int64_t axis = axis_attr.at(i).dyn_cast<::pir::Int64Attribute>().data();
if (axis < 0) {
Expand Down
Loading