Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelius84 committed Sep 8, 2023
1 parent ad788c6 commit 6c736fe
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 162 deletions.
2 changes: 1 addition & 1 deletion paddle/cinn/hlir/dialect/runtime/ir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if(NOT CINN_ONLY)
cinn_cc_library(cinn_runtime_dialect SRCS runtime_dialect.cc jit_kernel_op.cc
DEPS ir_core)
DEPS pir_core)
endif()
4 changes: 2 additions & 2 deletions paddle/cinn/runtime/cuda/float16.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,9 @@ __host__ __device__ inline bool(isfinite)(const float16& a) {

__host__ __device__ inline float16(abs)(const float16& a) {
#if defined(CINN_CUDA_FP16) && (defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530)
return float16(__habs(a.to_half()));
return static_cast<float16>(__habs(a.to_half()));
#else
return float16(fabsf(static_cast<float>(a)));
return static_cast<float16>(fabsf(static_cast<float>(a)));
#endif
}

Expand Down
12 changes: 6 additions & 6 deletions paddle/fluid/framework/executor_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#include "paddle/fluid/framework/new_executor/interpretercore.h"
#include "paddle/fluid/framework/op_info.h"
#include "paddle/fluid/ir/transforms/inplace_pass.h"
#include "paddle/fluid/ir/transforms/pd_op_to_kernel_pass.h"
#include "paddle/fluid/ir_adaptor/translator/translate.h"
#include "paddle/fluid/pir/transforms/inplace_pass.h"
#include "paddle/fluid/pir/transforms/pd_op_to_kernel_pass.h"
#include "paddle/pir/core/program.h"
#include "paddle/pir/core/value.h"
#include "paddle/pir/pass/pass.h"
Expand Down Expand Up @@ -444,8 +444,8 @@ std::unique_ptr<::pir::Program> ConstructFowardIrProgram(

auto ir_res = paddle::dialect::PdOpLowerToKernelPass(program.get());

::ir::PassManager pm(::ir::IrContext::Instance(), 3);
pm.AddPass(::ir::CreateInplacePass());
::pir::PassManager pm(::pir::IrContext::Instance(), 3);
pm.AddPass(::pir::CreateInplacePass());
pm.Run(ir_res.get());

return ir_res;
Expand Down Expand Up @@ -521,8 +521,8 @@ std::unique_ptr<::pir::Program> ConstructBackwardIrProgram(

auto res = paddle::dialect::PdOpLowerToKernelPass(program.get());

::ir::PassManager pm(::ir::IrContext::Instance(), 3);
pm.AddPass(::ir::CreateInplacePass());
::pir::PassManager pm(::pir::IrContext::Instance(), 3);
pm.AddPass(::pir::CreateInplacePass());
pm.Run(res.get());

return res;
Expand Down
13 changes: 6 additions & 7 deletions paddle/fluid/framework/new_executor/new_ir_interpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#include "paddle/pir/core/builtin_attribute.h"

PHI_DECLARE_bool(enable_new_ir_in_executor);

PHI_DECLARE_bool(enable_new_ir_in_executor_trace_run);

namespace paddle {
Expand Down Expand Up @@ -921,12 +920,12 @@ FetchList NewIRInterpreter::Run(const std::vector<std::string>& feed_names,
std::stringstream ss;
ss << this;
::pir::BuildScope(*ir_program_->block(),
InnerScope(),
ss.str(),
&value_2_var_name_,
&variable_2_var_name_,
&var_name_2_id_,
&variable_list_);
InnerScope(),
ss.str(),
&value_2_var_name_,
&variable_2_var_name_,
&var_name_2_id_,
&variable_list_);

interpreter::BuildId2VarName(var_name_2_id_, &id_2_var_name_);

Expand Down
65 changes: 0 additions & 65 deletions paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.cc

This file was deleted.

38 changes: 0 additions & 38 deletions paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.h

This file was deleted.

2 changes: 1 addition & 1 deletion paddle/fluid/pir/dialect/op_generator/op_interface_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
}

attr_data_map = {
'ir::StrAttribute': 'AsString',
'pir::StrAttribute': 'AsString',
}


Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pir/dialect/operator/interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ file(GLOB PD_INTERFACE_SRCS "*.cc")
cc_library(
pd_interface
SRCS ${PD_INTERFACE_SRCS}
DEPS ir_core phi_utils)
DEPS pir_core phi_utils)
2 changes: 1 addition & 1 deletion paddle/fluid/pir/dialect/operator/ir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ cc_library(
cc_library(
api_builder
SRCS api_builder.cc
DEPS ir_core)
DEPS pir_core)
cc_library(
pd_op_dialect_api
SRCS ${api_source_file} manual_api.cc
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/pir/dialect/operator/ir/manual_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,12 +636,12 @@ void IfOp::Build(pir::Builder &builder, // NOLINT
argument.AddOperand(cond);
argument.output_types.swap(output_types);
}
ir::Block *IfOp::true_block() {
pir::Block *IfOp::true_block() {
pir::Region &true_region = (*this)->region(0);
if (true_region.empty()) true_region.emplace_back();
return true_region.front();
}
ir::Block *IfOp::false_block() {
pir::Block *IfOp::false_block() {
pir::Region &false_region = (*this)->region(1);
if (false_region.empty()) false_region.emplace_back();
return false_region.front();
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pir/dialect/operator/trait/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ file(GLOB PD_INTERFACE_SRCS "*.cc")
cc_library(
pd_trait
SRCS ${PD_INTERFACE_SRCS}
DEPS ir_core)
DEPS pir_core)
2 changes: 1 addition & 1 deletion paddle/phi/core/meta_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License. */

#include "glog/logging.h"

#include "paddle/fluid/ir/dialect/operator/ir/meta_tensor.h"
#include "paddle/fluid/pir/dialect/operator/ir/meta_tensor.h"
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/distributed/auto_parallel/dist_tensor.h"
#include "paddle/phi/core/enforce.h"
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/core/utils/type_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ limitations under the License. */

#include <string>

#include "paddle/fluid/ir/dialect/operator/ir/meta_tensor.h"
#include "paddle/fluid/pir/dialect/operator/ir/meta_tensor.h"
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/backends/custom/custom_context.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
Expand Down
2 changes: 1 addition & 1 deletion paddle/pir/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set(NEWIR_BINARY_DIR "${PADDLE_BINARY_DIR}/paddle/pir")

file(GLOB IR_SRCS "*.cc")

ir_library(ir_core SRCS ${IR_SRCS} DEPS ddim)
ir_library(pir_core SRCS ${IR_SRCS} DEPS ddim)
2 changes: 1 addition & 1 deletion paddle/pir/dialect/shape/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
file(GLOB_RECURSE SHAPE_SRCS "*.cc")
ir_library(ir_shape SRCS ${SHAPE_SRCS} DEPS ir_core)
ir_library(pir_shape SRCS ${SHAPE_SRCS} DEPS pir_core)
2 changes: 1 addition & 1 deletion paddle/pir/pass/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
file(GLOB NEW_PASS_SRCS "*.cc")

ir_library(ir_pass SRCS ${NEW_PASS_SRCS} DEPS ir_core)
ir_library(pir_pass SRCS ${NEW_PASS_SRCS} DEPS pir_core)
26 changes: 13 additions & 13 deletions paddle/pir/pass/pass_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "paddle/pir/core/enforce.h"
#include "paddle/pir/core/macros.h"
#include "paddle/pir/pass/pass.h"

namespace pir {

class Pass;
Expand Down Expand Up @@ -80,18 +79,19 @@ class PassRegistrar {
msg)

// Register a new pass that can be applied on the IR.
#define REGISTER_IR_PASS(pass_type, pass_class) \
STATIC_ASSERT_PASS_GLOBAL_NAMESPACE( \
__reg_pass__##pass_type, \
"REGISTER_IR_PASS must be called in global namespace"); \
static ::pir::PassRegistrar<pass_class> __pass_registrar_##pass_type##__( \
#pass_type); \
int TouchPassRegistrar_##pass_type() { \
__pass_registrar_##pass_type##__.Touch(); \
return 0; \
} \
static ::pir::PassRegistrar<pass_class> &__pass_tmp_registrar_##pass_type##__ \
UNUSED = __pass_registrar_##pass_type##__
#define REGISTER_IR_PASS(pass_type, pass_class) \
STATIC_ASSERT_PASS_GLOBAL_NAMESPACE( \
__reg_pass__##pass_type, \
"REGISTER_IR_PASS must be called in global namespace"); \
static ::pir::PassRegistrar<pass_class> __pass_registrar_##pass_type##__( \
#pass_type); \
int TouchPassRegistrar_##pass_type() { \
__pass_registrar_##pass_type##__.Touch(); \
return 0; \
} \
static ::pir::PassRegistrar<pass_class> \
&__pass_tmp_registrar_##pass_type##__ UNUSED = \
__pass_registrar_##pass_type##__

#define USE_PASS(pass_type) \
STATIC_ASSERT_PASS_GLOBAL_NAMESPACE( \
Expand Down
2 changes: 1 addition & 1 deletion paddle/pir/pattern_rewrite/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
file(GLOB PATTERN_SRCS "*.cc")

ir_library(ir_pattern_rewrite SRCS ${PATTERN_SRCS} DEPS ir_core)
ir_library(pir_pattern_rewrite SRCS ${PATTERN_SRCS} DEPS pir_core)
8 changes: 4 additions & 4 deletions paddle/pir/transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
file(GLOB PATTERN_SRCS "*.cc")

ir_library(
ir_builtin_transforms
pir_builtin_transforms
SRCS
${PATTERN_SRCS}
DEPS
ir_core
ir_pattern_rewrite
ir_pass)
pir_core
pir_pattern_rewrite
pir_pass)
26 changes: 13 additions & 13 deletions test/cpp/pir/control_flow_dialect/if_op_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,45 @@
#include <gtest/gtest.h>
#include <iostream>

#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_dialect.h"
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_manual_op.h"
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_op.h"
#include "paddle/fluid/pir/dialect/operator/ir/manual_op.h"
#include "paddle/fluid/pir/dialect/operator/ir/op_dialect.h"
#include "paddle/fluid/pir/dialect/operator/ir/pd_op.h"
#include "paddle/pir/core/builder.h"
#include "paddle/pir/core/builtin_op.h"
#include "paddle/pir/core/program.h"
#include "paddle/pir/dialect/control_flow/ir/cf_dialect.h"
#include "paddle/pir/dialect/control_flow/ir/cf_ops.h"

TEST(if_op_test, base) {
ir::IrContext* ctx = ir::IrContext::Instance();
pir::IrContext* ctx = pir::IrContext::Instance();
ctx->GetOrRegisterDialect<paddle::dialect::PaddleDialect>();
ctx->GetOrRegisterDialect<ir::ControlFlowDialect>();
ctx->GetOrRegisterDialect<pir::ControlFlowDialect>();

ir::Program program(ctx);
ir::Block* block = program.block();
ir::Builder builder(ctx, block);
pir::Program program(ctx);
pir::Block* block = program.block();
pir::Builder builder(ctx, block);

auto full_op = builder.Build<paddle::dialect::FullOp>(
std::vector<int64_t>{1}, true, phi::DataType::BOOL);

auto if_op = builder.Build<paddle::dialect::IfOp>(
full_op.out(), std::vector<ir::Type>{builder.bool_type()});
full_op.out(), std::vector<pir::Type>{builder.bool_type()});

ir::Block* true_block = if_op.true_block();
pir::Block* true_block = if_op.true_block();

builder.SetInsertionPointToStart(true_block);

auto full_op_1 = builder.Build<paddle::dialect::FullOp>(
std::vector<int64_t>{2}, true, phi::DataType::BOOL);
builder.Build<ir::YieldOp>(std::vector<ir::OpResult>{full_op_1.out()});
builder.Build<pir::YieldOp>(std::vector<pir::OpResult>{full_op_1.out()});

ir::Block* false_block = if_op.false_block();
pir::Block* false_block = if_op.false_block();

builder.SetInsertionPointToStart(false_block);

auto full_op_2 = builder.Build<paddle::dialect::FullOp>(
std::vector<int64_t>{3}, true, phi::DataType::BOOL);
builder.Build<ir::YieldOp>(std::vector<ir::OpResult>{full_op_2.out()});
builder.Build<pir::YieldOp>(std::vector<pir::OpResult>{full_op_2.out()});

std::stringstream ss;
program.Print(ss);
Expand Down
2 changes: 1 addition & 1 deletion tools/coverage/paddle_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function gen_full_html_report() {
'/paddle/paddle/fluid/recordio/*' \
'/paddle/paddle/fluid/string/*' \
'/paddle/paddle/fluid/eager/*' \
'/paddle/paddle/fluid/ir/*' \
'/paddle/paddle/fluid/pir/*' \
'/paddle/paddle/fluid/ir_adaptor/*' \
'/paddle/paddle/phi/*' \
'/paddle/paddle/pir/*' \
Expand Down

0 comments on commit 6c736fe

Please sign in to comment.