From 6c736fe9f40960e3a7de2569407384bb6598da52 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Fri, 8 Sep 2023 14:58:06 +0000 Subject: [PATCH] fix merge conflict --- .../hlir/dialect/runtime/ir/CMakeLists.txt | 2 +- paddle/cinn/runtime/cuda/float16.h | 4 +- paddle/fluid/framework/executor_cache.cc | 12 ++-- .../new_executor/new_ir_interpreter.cc | 13 ++-- .../pir/dialect/kernel/ir/legacy_kernel_op.cc | 65 ------------------- .../pir/dialect/kernel/ir/legacy_kernel_op.h | 38 ----------- .../dialect/op_generator/op_interface_gen.py | 2 +- .../dialect/operator/interface/CMakeLists.txt | 2 +- .../pir/dialect/operator/ir/CMakeLists.txt | 2 +- .../pir/dialect/operator/ir/manual_op.cc | 4 +- .../pir/dialect/operator/trait/CMakeLists.txt | 2 +- paddle/phi/core/meta_tensor.cc | 2 +- paddle/phi/core/utils/type_info.cc | 2 +- paddle/pir/core/CMakeLists.txt | 2 +- paddle/pir/dialect/shape/CMakeLists.txt | 2 +- paddle/pir/pass/CMakeLists.txt | 2 +- paddle/pir/pass/pass_registry.h | 26 ++++---- paddle/pir/pattern_rewrite/CMakeLists.txt | 2 +- paddle/pir/transforms/CMakeLists.txt | 8 +-- .../pir/control_flow_dialect/if_op_test.cc | 26 ++++---- tools/coverage/paddle_coverage.sh | 2 +- 21 files changed, 58 insertions(+), 162 deletions(-) delete mode 100644 paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.cc delete mode 100644 paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.h diff --git a/paddle/cinn/hlir/dialect/runtime/ir/CMakeLists.txt b/paddle/cinn/hlir/dialect/runtime/ir/CMakeLists.txt index f5ee6697b2f1a..6023117faee09 100644 --- a/paddle/cinn/hlir/dialect/runtime/ir/CMakeLists.txt +++ b/paddle/cinn/hlir/dialect/runtime/ir/CMakeLists.txt @@ -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() diff --git a/paddle/cinn/runtime/cuda/float16.h b/paddle/cinn/runtime/cuda/float16.h index cae59186dc832..d64731387d596 100644 --- a/paddle/cinn/runtime/cuda/float16.h +++ b/paddle/cinn/runtime/cuda/float16.h @@ -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(__habs(a.to_half())); #else - return float16(fabsf(static_cast(a))); + return static_cast(fabsf(static_cast(a))); #endif } diff --git a/paddle/fluid/framework/executor_cache.cc b/paddle/fluid/framework/executor_cache.cc index e00b42f232fb6..2a595659cb33a 100644 --- a/paddle/fluid/framework/executor_cache.cc +++ b/paddle/fluid/framework/executor_cache.cc @@ -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" @@ -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; @@ -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; diff --git a/paddle/fluid/framework/new_executor/new_ir_interpreter.cc b/paddle/fluid/framework/new_executor/new_ir_interpreter.cc index de30591980fd0..e35755c85c29d 100644 --- a/paddle/fluid/framework/new_executor/new_ir_interpreter.cc +++ b/paddle/fluid/framework/new_executor/new_ir_interpreter.cc @@ -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 { @@ -921,12 +920,12 @@ FetchList NewIRInterpreter::Run(const std::vector& 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_); diff --git a/paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.cc b/paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.cc deleted file mode 100644 index 663c49efcd57b..0000000000000 --- a/paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2023 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. - -#include "paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.h" -#include "paddle/fluid/pir/dialect/kernel/ir/kernel_attribute.h" -#include "paddle/phi/core/enforce.h" -#include "paddle/pir/core/builtin_attribute.h" - -namespace paddle { -namespace dialect { - -const char* LegacyKernelOp::attributes_name[attributes_num] = { // NOLINT - "op_name", - "kernel_name", - "kernel_key"}; - -void LegacyKernelOp::Verify() { - VLOG(4) << "Verifying inputs, outputs and attributes for: LegacyKernelOp."; - - auto& attributes = this->attributes(); - - PADDLE_ENFORCE(attributes.count("op_name") > 0 && - attributes.at("op_name").isa(), - phi::errors::PreconditionNotMet( - "Type of attribute: op_name is not right.")); - - PADDLE_ENFORCE(attributes.count("kernel_name") > 0 && - attributes.at("kernel_name").isa(), - phi::errors::PreconditionNotMet( - "Type of attribute: kernel_name is not right.")); - - PADDLE_ENFORCE(attributes.count("kernel_key") > 0 && - attributes.at("kernel_key").isa(), - phi::errors::PreconditionNotMet( - "Type of attribute: kernel_key is not right.")); -} - -std::string LegacyKernelOp::op_name() { - return attributes().at("op_name").dyn_cast().AsString(); -} -std::string LegacyKernelOp::kernel_name() { - return attributes() - .at("kernel_name") - .dyn_cast() - .AsString(); -} -phi::KernelKey LegacyKernelOp::kernel_key() { - return attributes().at("kernel_key").dyn_cast().data(); -} - -} // namespace dialect -} // namespace paddle - -IR_DEFINE_EXPLICIT_TYPE_ID(paddle::dialect::LegacyKernelOp) diff --git a/paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.h b/paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.h deleted file mode 100644 index b293dcf54336d..0000000000000 --- a/paddle/fluid/pir/dialect/kernel/ir/legacy_kernel_op.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2023 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 "paddle/phi/core/kernel_factory.h" -#include "paddle/pir/core/builder.h" -#include "paddle/pir/core/op_base.h" - -namespace paddle { -namespace dialect { -class LegacyKernelOp : public pir::Op { - public: - using Op::Op; - static const char *name() { return "pd_kernel.legacy_kernel"; } - static constexpr uint32_t attributes_num = 3; - static const char *attributes_name[attributes_num]; - std::string op_name(); - std::string kernel_name(); - phi::KernelKey kernel_key(); - void Verify(); -}; - -} // namespace dialect -} // namespace paddle - -IR_DECLARE_EXPLICIT_TYPE_ID(paddle::dialect::LegacyKernelOp) diff --git a/paddle/fluid/pir/dialect/op_generator/op_interface_gen.py b/paddle/fluid/pir/dialect/op_generator/op_interface_gen.py index 36b20c5fadbaf..03b0c3ff28c6c 100644 --- a/paddle/fluid/pir/dialect/op_generator/op_interface_gen.py +++ b/paddle/fluid/pir/dialect/op_generator/op_interface_gen.py @@ -93,7 +93,7 @@ } attr_data_map = { - 'ir::StrAttribute': 'AsString', + 'pir::StrAttribute': 'AsString', } diff --git a/paddle/fluid/pir/dialect/operator/interface/CMakeLists.txt b/paddle/fluid/pir/dialect/operator/interface/CMakeLists.txt index 05e14f1e26efb..a6496585e7790 100644 --- a/paddle/fluid/pir/dialect/operator/interface/CMakeLists.txt +++ b/paddle/fluid/pir/dialect/operator/interface/CMakeLists.txt @@ -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) diff --git a/paddle/fluid/pir/dialect/operator/ir/CMakeLists.txt b/paddle/fluid/pir/dialect/operator/ir/CMakeLists.txt index c644bee1bc224..71df1b6811bf7 100644 --- a/paddle/fluid/pir/dialect/operator/ir/CMakeLists.txt +++ b/paddle/fluid/pir/dialect/operator/ir/CMakeLists.txt @@ -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 diff --git a/paddle/fluid/pir/dialect/operator/ir/manual_op.cc b/paddle/fluid/pir/dialect/operator/ir/manual_op.cc index 28149431a2ec5..0787eb8e7f6c2 100644 --- a/paddle/fluid/pir/dialect/operator/ir/manual_op.cc +++ b/paddle/fluid/pir/dialect/operator/ir/manual_op.cc @@ -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(); diff --git a/paddle/fluid/pir/dialect/operator/trait/CMakeLists.txt b/paddle/fluid/pir/dialect/operator/trait/CMakeLists.txt index 53c3060d6f182..0689edb35655e 100644 --- a/paddle/fluid/pir/dialect/operator/trait/CMakeLists.txt +++ b/paddle/fluid/pir/dialect/operator/trait/CMakeLists.txt @@ -3,4 +3,4 @@ file(GLOB PD_INTERFACE_SRCS "*.cc") cc_library( pd_trait SRCS ${PD_INTERFACE_SRCS} - DEPS ir_core) + DEPS pir_core) diff --git a/paddle/phi/core/meta_tensor.cc b/paddle/phi/core/meta_tensor.cc index ac9ba900706b4..8c1dddfeafa21 100644 --- a/paddle/phi/core/meta_tensor.cc +++ b/paddle/phi/core/meta_tensor.cc @@ -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" diff --git a/paddle/phi/core/utils/type_info.cc b/paddle/phi/core/utils/type_info.cc index 867ff93637466..2cb903fde7310 100644 --- a/paddle/phi/core/utils/type_info.cc +++ b/paddle/phi/core/utils/type_info.cc @@ -14,7 +14,7 @@ limitations under the License. */ #include -#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" diff --git a/paddle/pir/core/CMakeLists.txt b/paddle/pir/core/CMakeLists.txt index 7254671ae5c4f..ceddcb89d9f52 100644 --- a/paddle/pir/core/CMakeLists.txt +++ b/paddle/pir/core/CMakeLists.txt @@ -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) diff --git a/paddle/pir/dialect/shape/CMakeLists.txt b/paddle/pir/dialect/shape/CMakeLists.txt index 62d7c0d42c85c..0798e78f2b15a 100644 --- a/paddle/pir/dialect/shape/CMakeLists.txt +++ b/paddle/pir/dialect/shape/CMakeLists.txt @@ -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) diff --git a/paddle/pir/pass/CMakeLists.txt b/paddle/pir/pass/CMakeLists.txt index b4a1d99ab5fcd..92f7de3531cf4 100644 --- a/paddle/pir/pass/CMakeLists.txt +++ b/paddle/pir/pass/CMakeLists.txt @@ -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) diff --git a/paddle/pir/pass/pass_registry.h b/paddle/pir/pass/pass_registry.h index 86c71d9e4ab32..71140810b0324 100644 --- a/paddle/pir/pass/pass_registry.h +++ b/paddle/pir/pass/pass_registry.h @@ -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; @@ -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_registrar_##pass_type##__( \ - #pass_type); \ - int TouchPassRegistrar_##pass_type() { \ - __pass_registrar_##pass_type##__.Touch(); \ - return 0; \ - } \ - static ::pir::PassRegistrar &__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_registrar_##pass_type##__( \ + #pass_type); \ + int TouchPassRegistrar_##pass_type() { \ + __pass_registrar_##pass_type##__.Touch(); \ + return 0; \ + } \ + static ::pir::PassRegistrar \ + &__pass_tmp_registrar_##pass_type##__ UNUSED = \ + __pass_registrar_##pass_type##__ #define USE_PASS(pass_type) \ STATIC_ASSERT_PASS_GLOBAL_NAMESPACE( \ diff --git a/paddle/pir/pattern_rewrite/CMakeLists.txt b/paddle/pir/pattern_rewrite/CMakeLists.txt index e99611a4ca050..27e939f5d05b9 100644 --- a/paddle/pir/pattern_rewrite/CMakeLists.txt +++ b/paddle/pir/pattern_rewrite/CMakeLists.txt @@ -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) diff --git a/paddle/pir/transforms/CMakeLists.txt b/paddle/pir/transforms/CMakeLists.txt index 2b9f63a64d4f9..4f9f0fa196e9a 100644 --- a/paddle/pir/transforms/CMakeLists.txt +++ b/paddle/pir/transforms/CMakeLists.txt @@ -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) diff --git a/test/cpp/pir/control_flow_dialect/if_op_test.cc b/test/cpp/pir/control_flow_dialect/if_op_test.cc index b1ada215a83be..78d1ccec4ad8e 100644 --- a/test/cpp/pir/control_flow_dialect/if_op_test.cc +++ b/test/cpp/pir/control_flow_dialect/if_op_test.cc @@ -14,9 +14,9 @@ #include #include -#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" @@ -24,35 +24,35 @@ #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(); - ctx->GetOrRegisterDialect(); + ctx->GetOrRegisterDialect(); - 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( std::vector{1}, true, phi::DataType::BOOL); auto if_op = builder.Build( - full_op.out(), std::vector{builder.bool_type()}); + full_op.out(), std::vector{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( std::vector{2}, true, phi::DataType::BOOL); - builder.Build(std::vector{full_op_1.out()}); + builder.Build(std::vector{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( std::vector{3}, true, phi::DataType::BOOL); - builder.Build(std::vector{full_op_2.out()}); + builder.Build(std::vector{full_op_2.out()}); std::stringstream ss; program.Print(ss); diff --git a/tools/coverage/paddle_coverage.sh b/tools/coverage/paddle_coverage.sh index 47958b472e5d0..7f2b80a9a2427 100644 --- a/tools/coverage/paddle_coverage.sh +++ b/tools/coverage/paddle_coverage.sh @@ -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/*' \