Skip to content

Commit ad788c6

Browse files
committed
fix merge error
1 parent 33875f2 commit ad788c6

29 files changed

+290
-92
lines changed

paddle/fluid/framework/type_info.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License. */
1616
#include "paddle/fluid/framework/feed_fetch_type.h"
1717
#include "paddle/fluid/framework/raw_tensor.h"
1818
#include "paddle/fluid/framework/string_array.h"
19-
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_meta_tensor.h"
19+
#include "paddle/fluid/pir/dialect/operator/ir/meta_tensor.h"
2020
#include "paddle/fluid/prim/utils/static/desc_tensor.h"
2121
#include "paddle/fluid/primitive/type/lazy_tensor.h"
2222

paddle/fluid/pir/dialect/kernel/ir/kernel_dialect.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#include "paddle/fluid/pir/dialect/kernel/ir/kernel_op.h"
1818
#include "paddle/fluid/pir/dialect/kernel/ir/kernel_type.h"
1919
#include "paddle/fluid/platform/init_phi.h"
20-
#include "paddle/pir/core/ir_printer.h"
2120
#include "paddle/phi/common/place.h"
2221
#include "paddle/phi/core/ddim.h"
22+
#include "paddle/pir/core/ir_printer.h"
2323

2424
REGISTER_FILE_SYMBOLS(kernel_dialect);
2525

@@ -75,8 +75,8 @@ void PaddleKernelDialect::PrintAttribute(pir::Attribute attr,
7575
<< "|dtype:" << kernel.dtype() << ">";
7676
}
7777

78-
void PaddleKernelDialect::PrintOperation(ir::Operation *op,
79-
ir::IrPrinter &printer) const {
78+
void PaddleKernelDialect::PrintOperation(pir::Operation *op,
79+
pir::IrPrinter &printer) const {
8080
if (op->dyn_cast<PhiKernelOp>() || op->dyn_cast<LegacyKernelOp>()) {
8181
auto &os = printer.os;
8282
printer.PrintOpResult(op);
@@ -86,7 +86,7 @@ void PaddleKernelDialect::PrintOperation(ir::Operation *op,
8686
if (op->attributes().count("is_inplace") != 0 &&
8787
op->attributes()
8888
.at("is_inplace")
89-
.dyn_cast<ir::BoolAttribute>()
89+
.dyn_cast<pir::BoolAttribute>()
9090
.data()) {
9191
kernel_name = kernel_name + "_";
9292
}
@@ -97,7 +97,7 @@ void PaddleKernelDialect::PrintOperation(ir::Operation *op,
9797
if (op->attributes().count("is_inplace") != 0 &&
9898
op->attributes()
9999
.at("is_inplace")
100-
.dyn_cast<ir::BoolAttribute>()
100+
.dyn_cast<pir::BoolAttribute>()
101101
.data()) {
102102
kernel_name = kernel_name + "_";
103103
}

paddle/fluid/pir/dialect/kernel/ir/kernel_dialect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class PaddleKernelDialect : public pir::Dialect {
2929

3030
void PrintAttribute(pir::Attribute attr, std::ostream& os) const override;
3131

32-
void PrintOperation(ir::Operation* op,
33-
ir::IrPrinter& printer) const override; // NOLINT
32+
void PrintOperation(pir::Operation* op,
33+
pir::IrPrinter& printer) const override; // NOLINT
3434

3535
private:
3636
void initialize();

paddle/fluid/pir/dialect/kernel/ir/kernel_op.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ void LegacyKernelOp::Verify() {
7070
auto& attributes = this->attributes();
7171

7272
PADDLE_ENFORCE(attributes.count("op_name") > 0 &&
73-
attributes.at("op_name").isa<ir::StrAttribute>(),
73+
attributes.at("op_name").isa<pir::StrAttribute>(),
7474
phi::errors::PreconditionNotMet(
7575
"Type of attribute: op_name is not right."));
7676

7777
PADDLE_ENFORCE(attributes.count("kernel_name") > 0 &&
78-
attributes.at("kernel_name").isa<ir::StrAttribute>(),
78+
attributes.at("kernel_name").isa<pir::StrAttribute>(),
7979
phi::errors::PreconditionNotMet(
8080
"Type of attribute: kernel_name is not right."));
8181

@@ -86,10 +86,13 @@ void LegacyKernelOp::Verify() {
8686
}
8787

8888
std::string LegacyKernelOp::op_name() {
89-
return attributes().at("op_name").dyn_cast<ir::StrAttribute>().AsString();
89+
return attributes().at("op_name").dyn_cast<pir::StrAttribute>().AsString();
9090
}
9191
std::string LegacyKernelOp::kernel_name() {
92-
return attributes().at("kernel_name").dyn_cast<ir::StrAttribute>().AsString();
92+
return attributes()
93+
.at("kernel_name")
94+
.dyn_cast<pir::StrAttribute>()
95+
.AsString();
9396
}
9497
phi::KernelKey LegacyKernelOp::kernel_key() {
9598
return attributes().at("kernel_key").dyn_cast<KernelAttribute>().data();

paddle/fluid/pir/dialect/op_generator/op_build_gen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,16 +323,16 @@ def GenBuildOutputs(
323323
CREATE_SCALAR_MUTABLE_ATTRIBUE_TEMPLATE = """ {dtype} {name} = {name}_.owner()->dyn_cast<paddle::dialect::FullOp>().attributes().at("value").dyn_cast<paddle::dialect::ScalarAttribute>().data().to<{dtype}>(); (void){name};\n"""
324324

325325
CREATE_INTARRAY_MUTABLE_ATTRIBUE_WITH_UNKONW_DATA_TEMPLATE = """ phi::IntArray {name};
326-
if ({name}_.owner()->info().id() == ir::TypeId::get<paddle::dialect::FullIntArrayOp>()) {{
326+
if ({name}_.owner()->info().id() == pir::TypeId::get<paddle::dialect::FullIntArrayOp>()) {{
327327
{name} = std::move(phi::IntArray({name}_.owner()
328328
->dyn_cast<paddle::dialect::FullIntArrayOp>()
329329
.attributes()
330330
.at("value")
331331
.dyn_cast<paddle::dialect::IntArrayAttribute>()
332332
.data()
333333
.GetData()));
334-
}} else if ({name}_.type().isa<ir::VectorType>()) {{
335-
size_t {name}_size = {name}_.type().dyn_cast<ir::VectorType>().size();
334+
}} else if ({name}_.type().isa<pir::VectorType>()) {{
335+
size_t {name}_size = {name}_.type().dyn_cast<pir::VectorType>().size();
336336
{name} = std::move(phi::IntArray(std::vector<int64_t>({name}_size, -1)));
337337
{name}.SetFromTensor(true);
338338
}} else if ({name}_.type().isa<paddle::dialect::DenseTensorType>()) {{
@@ -344,7 +344,7 @@ def GenBuildOutputs(
344344
}}\n"""
345345

346346
CREATE_SCALAR_MUTABLE_ATTRIBUE_WITH_UNKONW_DATA_TEMPLATE = """ phi::Scalar {name};
347-
if ({name}_.owner()->info().id() == ir::TypeId::get<paddle::dialect::FullOp>()) {{
347+
if ({name}_.owner()->info().id() == pir::TypeId::get<paddle::dialect::FullOp>()) {{
348348
{name} = std::move(phi::Scalar({name}_.owner()
349349
->dyn_cast<paddle::dialect::FullOp>()
350350
.attributes()

paddle/fluid/pir/dialect/op_generator/op_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class {op_name} : public pir::Op<{op_name}{interfaces}{traits}> {{
101101
#include "{h_file}"
102102
#include "paddle/fluid/pir/dialect/operator/ir/op_type.h"
103103
#include "paddle/fluid/pir/dialect/operator/ir/op_attribute.h"
104-
#include "paddle/fluid/pir/dialect/operator/ir/pd_meta_tensor.h"
104+
#include "paddle/fluid/pir/dialect/operator/ir/meta_tensor.h"
105105
#include "paddle/pir/core/builtin_attribute.h"
106106
#include "paddle/pir/core/builtin_type.h"
107107
#include "paddle/pir/core/builtin_op.h"

paddle/fluid/pir/dialect/operator/ir/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ add_custom_target(ops_api_gen ALL DEPENDS ${ops_api_source_file})
186186

187187
cc_library(
188188
pd_op_dialect_core
189-
SRCS op_attribute.cc op_type.cc pd_meta_tensor.cc
189+
SRCS op_attribute.cc op_type.cc meta_tensor.cc
190190
DEPS phi pd_interface pd_trait type_info)
191191
cc_library(
192192
pd_op_dialect_op

paddle/fluid/pir/dialect/operator/ir/manual_op.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ void AddNWithKernelOp::Build(pir::Builder &builder,
310310
VLOG(4) << "Builder construction attributes";
311311

312312
VLOG(4) << "Builder construction outputs";
313-
ir::VectorType inputs = inputs_.type().dyn_cast<ir::VectorType>();
314-
(void)inputs;
313+
pir::VectorType inputs = inputs_.type().dyn_cast<pir::VectorType>();
315314
std::vector<phi::DenseTensor> vec_dense_inputs;
316315
for (size_t i = 0; i < static_cast<size_t>(inputs.size()); i++) {
317316
vec_dense_inputs.push_back(phi::DenseTensor(
@@ -629,25 +628,25 @@ void SplitGradOp::InferMeta(phi::InferMetaContext *infer_meta) {
629628
fn(infer_meta);
630629
}
631630

632-
void IfOp::Build(ir::Builder &builder, // NOLINT
633-
ir::OperationArgument &argument, // NOLINT
634-
ir::OpResult cond,
635-
std::vector<ir::Type> &&output_types) {
631+
void IfOp::Build(pir::Builder &builder, // NOLINT
632+
pir::OperationArgument &argument, // NOLINT
633+
pir::OpResult cond,
634+
std::vector<pir::Type> &&output_types) {
636635
argument.num_regions = 2;
637636
argument.AddOperand(cond);
638637
argument.output_types.swap(output_types);
639638
}
640639
ir::Block *IfOp::true_block() {
641-
ir::Region &true_region = (*this)->region(0);
640+
pir::Region &true_region = (*this)->region(0);
642641
if (true_region.empty()) true_region.emplace_back();
643642
return true_region.front();
644643
}
645644
ir::Block *IfOp::false_block() {
646-
ir::Region &false_region = (*this)->region(1);
645+
pir::Region &false_region = (*this)->region(1);
647646
if (false_region.empty()) false_region.emplace_back();
648647
return false_region.front();
649648
}
650-
void IfOp::Print(ir::IrPrinter &printer) {
649+
void IfOp::Print(pir::IrPrinter &printer) {
651650
auto &os = printer.os;
652651
auto op = operation();
653652
printer.PrintOpResult(op);

paddle/fluid/pir/dialect/operator/ir/manual_op.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#ifdef GET_MANUAL_OP_LIST
1616
#undef GET_MANUAL_OP_LIST
17-
paddle::dialect::AddNOp, paddle::dialect::SplitGradOp
17+
paddle::dialect::AddNOp, paddle::dialect::SplitGradOp, paddle::dialect::IfOp
1818

1919
#else
2020

@@ -29,6 +29,7 @@ paddle::dialect::AddNOp, paddle::dialect::SplitGradOp
2929
#include "paddle/fluid/pir/dialect/operator/utils/utils.h"
3030
#include "paddle/phi/core/infermeta_utils.h"
3131
#include "paddle/pir/core/builder.h"
32+
#include "paddle/pir/core/ir_printer.h"
3233
#include "paddle/pir/core/op_base.h"
3334
#include "paddle/pir/core/operation_utils.h"
3435

@@ -116,12 +117,29 @@ class SplitGradOp : public pir::Op<SplitGradOp, OpYamlInfoInterface> {
116117
static void InferMeta(phi::InferMetaContext *infer_meta);
117118
};
118119

120+
class IfOp : public pir::Op<IfOp> {
121+
public:
122+
using Op::Op;
123+
static const char *name() { return "pd.if"; }
124+
static constexpr const char **attributes_name = nullptr;
125+
static constexpr uint32_t attributes_num = 0;
126+
static void Build(pir::Builder &builder, // NOLINT
127+
pir::OperationArgument &argument, // NOLINT
128+
pir::OpResult cond,
129+
std::vector<pir::Type> &&output_types);
130+
pir::Value cond() { return operand_source(0); }
131+
pir::Block *true_block();
132+
pir::Block *false_block();
133+
void Print(pir::IrPrinter &printer); // NOLINT
134+
void Verify();
135+
};
136+
119137
} // namespace dialect
120138
} // namespace paddle
121139

122140
IR_DECLARE_EXPLICIT_TYPE_ID(paddle::dialect::AddNOp)
123141
IR_DECLARE_EXPLICIT_TYPE_ID(paddle::dialect::SplitGradOp)
124142
IR_DECLARE_EXPLICIT_TYPE_ID(paddle::dialect::AddN_Op)
125143
IR_DECLARE_EXPLICIT_TYPE_ID(paddle::dialect::AddNWithKernelOp)
126-
144+
IR_DECLARE_EXPLICIT_TYPE_ID(paddle::dialect::IfOp)
127145
#endif

paddle/fluid/ir/dialect/paddle_dialect/ir/pd_meta_tensor.cc renamed to paddle/fluid/pir/dialect/operator/ir/meta_tensor.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_meta_tensor.h"
15+
#include "paddle/fluid/pir/dialect/operator/ir/meta_tensor.h"
1616

17-
#include "paddle/ir/core/enforce.h"
17+
#include "paddle/pir/core/enforce.h"
1818

1919
namespace paddle {
2020
namespace dialect {

paddle/fluid/pir/transforms/pd_op_to_kernel_pass.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ void DealWithSpecialBuiltinOps(
192192
auto new_in = GetNewInput(cur_in, *map_value_pair, i, op_item->name());
193193
vec_inputs.push_back(new_in);
194194

195-
if (new_in.type().isa<ir::VectorType>()) {
196-
auto vec_types = new_in.type().dyn_cast<ir::VectorType>().data();
195+
if (new_in.type().isa<pir::VectorType>()) {
196+
auto vec_types = new_in.type().dyn_cast<pir::VectorType>().data();
197197
for (uint64_t idx = 0; idx < vec_types.size(); idx++) {
198198
op_output_types.push_back(vec_types[idx]);
199199
}

paddle/ir/dialect/control_flow/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

paddle/phi/core/meta_tensor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License. */
1616

1717
#include "glog/logging.h"
1818

19-
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_meta_tensor.h"
19+
#include "paddle/fluid/ir/dialect/operator/ir/meta_tensor.h"
2020
#include "paddle/phi/core/dense_tensor.h"
2121
#include "paddle/phi/core/distributed/auto_parallel/dist_tensor.h"
2222
#include "paddle/phi/core/enforce.h"

paddle/phi/core/utils/type_info.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License. */
1414

1515
#include <string>
1616

17-
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_meta_tensor.h"
17+
#include "paddle/fluid/ir/dialect/operator/ir/meta_tensor.h"
1818
#include "paddle/phi/backends/cpu/cpu_context.h"
1919
#include "paddle/phi/backends/custom/custom_context.h"
2020
#include "paddle/phi/backends/gpu/gpu_context.h"

paddle/pir/core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
set(NEWIR_SOURCE_DIR "${PADDLE_SOURCE_DIR}/paddle/ir")
2-
set(NEWIR_BINARY_DIR "${PADDLE_BINARY_DIR}/paddle/ir")
1+
set(NEWIR_SOURCE_DIR "${PADDLE_SOURCE_DIR}/paddle/pir")
2+
set(NEWIR_BINARY_DIR "${PADDLE_BINARY_DIR}/paddle/pir")
33

44
file(GLOB IR_SRCS "*.cc")
55

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
file(GLOB_RECURSE CONTROL_FLOW_SRCS "*.cc")
2+
ir_library(pir_control_flow SRCS ${CONTROL_FLOW_SRCS} DEPS pir_core)

paddle/ir/dialect/control_flow/ir/cf_dialect.cc renamed to paddle/pir/dialect/control_flow/ir/cf_dialect.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
#include "paddle/ir/dialect/control_flow/ir/cf_dialect.h"
15-
#include "paddle/ir/dialect/control_flow/ir/cf_ops.h"
14+
#include "paddle/pir/dialect/control_flow/ir/cf_dialect.h"
15+
#include "paddle/pir/dialect/control_flow/ir/cf_ops.h"
1616

17-
namespace ir {
17+
namespace pir {
1818
void ControlFlowDialect::initialize() { RegisterOps<YieldOp>(); }
19-
} // namespace ir
20-
IR_DEFINE_EXPLICIT_TYPE_ID(ir::ControlFlowDialect)
19+
} // namespace pir
20+
IR_DEFINE_EXPLICIT_TYPE_ID(pir::ControlFlowDialect)

paddle/ir/dialect/control_flow/ir/cf_dialect.h renamed to paddle/pir/dialect/control_flow/ir/cf_dialect.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
#pragma once
1616

17-
#include "paddle/ir/core/dialect.h"
17+
#include "paddle/pir/core/dialect.h"
1818

19-
namespace ir {
19+
namespace pir {
2020
class ControlFlowDialect : public Dialect {
2121
public:
2222
explicit ControlFlowDialect(IrContext *context)
@@ -29,5 +29,5 @@ class ControlFlowDialect : public Dialect {
2929
void initialize();
3030
};
3131

32-
} // namespace ir
33-
IR_DECLARE_EXPLICIT_TYPE_ID(ir::ControlFlowDialect)
32+
} // namespace pir
33+
IR_DECLARE_EXPLICIT_TYPE_ID(pir::ControlFlowDialect)

paddle/ir/dialect/control_flow/ir/cf_ops.cc renamed to paddle/pir/dialect/control_flow/ir/cf_ops.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "paddle/ir/dialect/control_flow/ir/cf_ops.h"
15+
#include "paddle/pir/dialect/control_flow/ir/cf_ops.h"
1616

17-
namespace ir {
17+
namespace pir {
1818

1919
void YieldOp::Build(Builder &builder,
2020
OperationArgument &argument,
2121
std::vector<OpResult> &&inputs) {
2222
argument.AddOperands(inputs.begin(), inputs.end());
2323
}
24-
} // namespace ir
24+
} // namespace pir
2525

26-
IR_DEFINE_EXPLICIT_TYPE_ID(ir::YieldOp)
26+
IR_DEFINE_EXPLICIT_TYPE_ID(pir::YieldOp)

paddle/ir/dialect/control_flow/ir/cf_ops.h renamed to paddle/pir/dialect/control_flow/ir/cf_ops.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
#pragma once
1616

17-
#include "paddle/ir/core/builder.h"
18-
#include "paddle/ir/core/op_base.h"
17+
#include "paddle/pir/core/builder.h"
18+
#include "paddle/pir/core/op_base.h"
1919

20-
namespace ir {
20+
namespace pir {
2121
class IR_API YieldOp : public Op<YieldOp> {
2222
public:
2323
using Op::Op;
@@ -30,6 +30,6 @@ class IR_API YieldOp : public Op<YieldOp> {
3030
std::vector<OpResult> &&inputs);
3131
void Verify() {}
3232
};
33-
} // namespace ir
33+
} // namespace pir
3434

35-
IR_EXPORT_DECLARE_EXPLICIT_TYPE_ID(ir::YieldOp);
35+
IR_EXPORT_DECLARE_EXPLICIT_TYPE_ID(pir::YieldOp);

paddle/pir/dialect/shape/utils/shape_utils.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,19 @@ bool SymbolicDimMgr::loadShapeConstraintGraph() {
6161
// TODO(liujinnan): add more constraint function. currently, only support
6262
// tie_product_equal.
6363
auto constraint_vec =
64-
symbolTable_.lookup<ir::dialect::TieProductEqualOp>("tie_product_equal");
64+
symbolTable_.lookup<pir::dialect::TieProductEqualOp>("tie_product_equal");
6565

6666
if (!constraint_vec.size()) return true;
6767

68-
auto build_sym_product = [&](std::vector<ir::Value> range,
68+
auto build_sym_product = [&](std::vector<pir::Value> range,
6969
SymbolicDimProduct& product) {
7070
for (Value v : range) {
7171
auto definingOp = v.GetDefiningOp();
72-
if (auto constOp = definingOp->dyn_cast<ir::ConstantOp>()) {
73-
product.factor *= constOp.value().dyn_cast<ir::Int32Attribute>().data();
72+
if (auto constOp = definingOp->dyn_cast<pir::ConstantOp>()) {
73+
product.factor *=
74+
constOp.value().dyn_cast<pir::Int32Attribute>().data();
7475
continue;
75-
} else if (auto dimOp = definingOp->dyn_cast<ir::dialect::DimOp>()) {
76+
} else if (auto dimOp = definingOp->dyn_cast<pir::dialect::DimOp>()) {
7677
auto sym = symbolTable_.lookup<SymbolicDim>(dimOp.getName());
7778
if (!sym) return false;
7879
product.symbols.push_back(sym);

0 commit comments

Comments
 (0)