From 5c75f7626bf955d68e26375abedab7fabda5e017 Mon Sep 17 00:00:00 2001 From: enkilee Date: Tue, 29 Jul 2025 15:49:25 +0800 Subject: [PATCH 1/2] rename namespace for TensorFormatter --- paddle/phi/kernels/assert_kernel.cc | 2 +- paddle/phi/kernels/funcs/tensor_formatter.cc | 6 ++---- paddle/phi/kernels/funcs/tensor_formatter.h | 6 ++---- paddle/phi/kernels/impl/data_impl.h | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/paddle/phi/kernels/assert_kernel.cc b/paddle/phi/kernels/assert_kernel.cc index efe96884c96d27..dd1964487fbed3 100644 --- a/paddle/phi/kernels/assert_kernel.cc +++ b/paddle/phi/kernels/assert_kernel.cc @@ -31,7 +31,7 @@ void AssertKernel(const Context& dev_ctx, return; } - paddle::funcs::TensorFormatter formatter; + phi::funcs::TensorFormatter formatter; formatter.SetSummarize(summarize); for (size_t i = 0; i < data.size(); ++i) { diff --git a/paddle/phi/kernels/funcs/tensor_formatter.cc b/paddle/phi/kernels/funcs/tensor_formatter.cc index 649209f1572b7e..7b9645c2912575 100644 --- a/paddle/phi/kernels/funcs/tensor_formatter.cc +++ b/paddle/phi/kernels/funcs/tensor_formatter.cc @@ -20,8 +20,7 @@ #include "paddle/phi/common/place.h" #include "paddle/phi/core/tensor_utils.h" -namespace paddle { -namespace funcs { +namespace phi::funcs { void TensorFormatter::SetPrintTensorType(bool print_tensor_type) { print_tensor_type_ = print_tensor_type; @@ -185,5 +184,4 @@ template void TensorFormatter::FormatData>( template void TensorFormatter::FormatData>( const phi::DenseTensor& print_tensor, std::stringstream& log_stream); -} // namespace funcs -} // namespace paddle +} // namespace phi::funcs diff --git a/paddle/phi/kernels/funcs/tensor_formatter.h b/paddle/phi/kernels/funcs/tensor_formatter.h index 0914ade6016ff0..f72ec9d3efa7ae 100644 --- a/paddle/phi/kernels/funcs/tensor_formatter.h +++ b/paddle/phi/kernels/funcs/tensor_formatter.h @@ -21,8 +21,7 @@ namespace phi { class DenseTensor; } // namespace phi -namespace paddle { -namespace funcs { +namespace phi::funcs { class TensorFormatter { public: @@ -54,5 +53,4 @@ class TensorFormatter { bool print_tensor_layout_ = true; }; -} // namespace funcs -} // namespace paddle +} // namespace phi::funcs diff --git a/paddle/phi/kernels/impl/data_impl.h b/paddle/phi/kernels/impl/data_impl.h index 824e1d0d780129..e0a9d69e79b553 100644 --- a/paddle/phi/kernels/impl/data_impl.h +++ b/paddle/phi/kernels/impl/data_impl.h @@ -105,7 +105,7 @@ void PrintKernel(const Context& dev_ctx, // if (first_n > 0 && ++times_ > first_n) return; // TODO(phlrain): support printed_var_name - paddle::funcs::TensorFormatter formatter; + phi::funcs::TensorFormatter formatter; const std::string& name = print_tensor_name ? "var" : ""; formatter.SetPrintTensorType(print_tensor_type); formatter.SetPrintTensorShape(print_tensor_shape); From ac309a41e3f33be26827570c343a168411cb1beb Mon Sep 17 00:00:00 2001 From: enkilee Date: Wed, 30 Jul 2025 10:17:56 +0800 Subject: [PATCH 2/2] fix error --- .../new_executor/instruction/control_flow/assert_instruction.cc | 2 +- paddle/fluid/operators/assert_op.cc | 2 +- paddle/fluid/operators/print_op.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/framework/new_executor/instruction/control_flow/assert_instruction.cc b/paddle/fluid/framework/new_executor/instruction/control_flow/assert_instruction.cc index 54fd497afa061b..081e57f66800b6 100644 --- a/paddle/fluid/framework/new_executor/instruction/control_flow/assert_instruction.cc +++ b/paddle/fluid/framework/new_executor/instruction/control_flow/assert_instruction.cc @@ -75,7 +75,7 @@ void AssertInstruction::Run() { return; } - funcs::TensorFormatter formatter; + phi::funcs::TensorFormatter formatter; formatter.SetSummarize( op_->attribute<::pir::Int64Attribute>("summarize").data()); diff --git a/paddle/fluid/operators/assert_op.cc b/paddle/fluid/operators/assert_op.cc index 99f9979ed4a0df..40b2aae95c617e 100644 --- a/paddle/fluid/operators/assert_op.cc +++ b/paddle/fluid/operators/assert_op.cc @@ -73,7 +73,7 @@ class AssertOp : public framework::OperatorBase { return; } - funcs::TensorFormatter formatter; + phi::funcs::TensorFormatter formatter; formatter.SetSummarize(Attr(kSummarize.data())); const std::vector &x_names = Inputs(kData.data()); diff --git a/paddle/fluid/operators/print_op.cc b/paddle/fluid/operators/print_op.cc index 8bb819efbd1376..a6ca37714ec868 100644 --- a/paddle/fluid/operators/print_op.cc +++ b/paddle/fluid/operators/print_op.cc @@ -87,7 +87,7 @@ class PrintOp : public framework::OperatorBase { int first_n = Attr("first_n"); if (first_n > 0 && ++times_ > first_n) return; - funcs::TensorFormatter formatter; + phi::funcs::TensorFormatter formatter; const std::string &name = Attr("print_tensor_name") ? printed_var_name : ""; formatter.SetPrintTensorType(Attr("print_tensor_type"));