Skip to content

Commit

Permalink
[CINN]Clean usless loop_reorder_aligment tactic (#63998)
Browse files Browse the repository at this point in the history
* [CINN]Clean usless loop_reorder_aligment tactic

* fix source
  • Loading branch information
Aurelius84 committed May 7, 2024
1 parent 0bd6669 commit 5ee37e1
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 189 deletions.
1 change: 0 additions & 1 deletion paddle/cinn/ir/group_schedule/dy_shape_group_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "paddle/cinn/ir/group_schedule/tactic/arrange_storage_tactic.h"
#include "paddle/cinn/ir/group_schedule/tactic/bind_cuda_tactic.h"
#include "paddle/cinn/ir/group_schedule/tactic/compute_inline_tactic.h"
#include "paddle/cinn/ir/group_schedule/tactic/loop_reorder_alignment_tactic.h"
#include "paddle/cinn/ir/group_schedule/tactic/optimize_reduction_tactic.h"
#include "paddle/cinn/ir/group_schedule/tactic/tile_first_general_tactic.h"
#include "paddle/cinn/ir/group_schedule/tactic/tile_tactic.h"
Expand Down
1 change: 0 additions & 1 deletion paddle/cinn/ir/group_schedule/tactic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ gather_srcs(cinnapi_src SRCS compute_inline_tactic.cc)
gather_srcs(cinnapi_src SRCS optimize_reduction_tactic.cc)
gather_srcs(cinnapi_src SRCS bind_cuda_tactic.cc)
gather_srcs(cinnapi_src SRCS arrange_storage_tactic.cc)
gather_srcs(cinnapi_src SRCS loop_reorder_alignment_tactic.cc)
gather_srcs(cinnapi_src SRCS tile_first_general_tactic.cc)
132 changes: 0 additions & 132 deletions paddle/cinn/ir/group_schedule/tactic/loop_reorder_alignment_tactic.cc

This file was deleted.

This file was deleted.

31 changes: 2 additions & 29 deletions paddle/fluid/pir/transforms/sub_graph_detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "paddle/cinn/hlir/dialect/operator/ir/manual_op.h"
#include "paddle/cinn/hlir/dialect/operator/ir/op_dialect.h"
#include "paddle/fluid/pir/dialect/operator/ir/pd_op.h"
#include "paddle/fluid/pir/utils/general_functions.h"
#include "paddle/pir/include/core/builder.h"
#include "paddle/pir/include/core/builtin_op.h"
#include "paddle/pir/include/dialect/control_flow/ir/cf_dialect.h"
Expand Down Expand Up @@ -484,34 +485,6 @@ std::vector<pir::Value> AnalysisOutputs(
return outputs;
}

std::vector<pir::Value> AnalysisExternalInputs(Operation* op) { // NOLINT
if (!op->isa<cinn::dialect::GroupOp>()) {
return op->operands_source();
}
// Get all ops in group
const auto all_ops = [&]() -> decltype(auto) {
const auto all_ops = op->dyn_cast<cinn::dialect::GroupOp>().GetOperators();
return std::unordered_set<pir::Operation*>(all_ops.begin(), all_ops.end());
}();
std::unordered_set<pir::Value> value_set;
const auto& IsOutsideInput = [&](const pir::Value& value) -> bool {
const bool is_outside =
value && value.defining_op() && !all_ops.count(value.defining_op());
const bool has_visited = value_set.count(value);
if (!has_visited) value_set.insert(value);
return is_outside && !has_visited;
};

std::vector<::pir::Value> inputs;
// count all op's input Value
for (auto inner_op : all_ops) {
for (auto& value : inner_op->operands_source()) {
if (IsOutsideInput(value)) inputs.push_back(value);
}
}
return inputs;
}

namespace {

pir::Operation* FindInsertPoint(const GroupOpsVec& group_ops,
Expand Down Expand Up @@ -576,7 +549,7 @@ std::unordered_set<pir::Operation*> GetUpstreamOpsAfterPosition(
}
return false;
};
std::vector<pir::Value> op_inputs = AnalysisExternalInputs(op);
std::vector<pir::Value> op_inputs = pir::GetUsedExternalValue(*op);
for (auto value : op_inputs) {
if (!value || !value.defining_op()) continue;
pir::Operation* defining_op = value.defining_op();
Expand Down

0 comments on commit 5ee37e1

Please sign in to comment.