diff --git a/paddle/cinn/hlir/framework/pir/utils.h b/paddle/cinn/hlir/framework/pir/utils.h index cd0f66af3f1ff4..b4ed9853dd760b 100644 --- a/paddle/cinn/hlir/framework/pir/utils.h +++ b/paddle/cinn/hlir/framework/pir/utils.h @@ -93,7 +93,7 @@ struct CompatibleInfo { static OpPatternKind OpKind(const ::pir::Operation& op); }; -std::vector GetBroadcastAxis(const phi::DDim& in_shape, +std::vector GetBroadcastAxis(const ::common::DDim& in_shape, const std::vector& out_shape); } // namespace pir diff --git a/paddle/common/ddim.h b/paddle/common/ddim.h index 4710708c70d4a2..9986f435395149 100644 --- a/paddle/common/ddim.h +++ b/paddle/common/ddim.h @@ -11,6 +11,7 @@ // 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 #include @@ -234,30 +235,10 @@ TEST_API DDim stride(const DDim& ddim); TEST_API DDim stride_numel(const DDim& ddim); } // namespace common -namespace paddle { -namespace framework { -using DDim = common::DDim; -} -} // namespace paddle - -namespace phi { -using DDim = common::DDim; -using common::arity; -using common::contain_unknown_dim; -using common::flatten_to_1d; -using common::flatten_to_2d; -using common::flatten_to_3d; -using common::make_ddim; -using common::product; -using common::slice_ddim; -using common::stride; -using common::stride_numel; -using common::vectorize; -} // namespace phi - namespace pir { using DDim = common::DDim; -} +using LoD = std::vector>; +} // namespace pir namespace std { template <> diff --git a/paddle/fluid/pir/transforms/transform_general_functions.h b/paddle/fluid/pir/transforms/transform_general_functions.h index c5f138daa41a79..7e63d6dba89030 100644 --- a/paddle/fluid/pir/transforms/transform_general_functions.h +++ b/paddle/fluid/pir/transforms/transform_general_functions.h @@ -43,7 +43,7 @@ std::string GetParameterNameFromValue(pir::Value value); * * @return const phi::DDim& */ -const phi::DDim& GetShapeFromValue(pir::Value value); +const common::DDim& GetShapeFromValue(pir::Value value); /** * @brief Get tensor's data type from a value. diff --git a/paddle/fluid/pybind/pir.h b/paddle/fluid/pybind/pir.h index 30c3e83af4a9e8..81ae155bbd28ef 100644 --- a/paddle/fluid/pybind/pir.h +++ b/paddle/fluid/pybind/pir.h @@ -15,8 +15,8 @@ #pragma once #include -#include "paddle/common/ddim.h" #include "paddle/phi/common/data_type.h" +#include "paddle/phi/core/ddim.h" #include "paddle/pir/core/op_result.h" namespace paddle { diff --git a/paddle/phi/api/profiler/supplement_tracing.h b/paddle/phi/api/profiler/supplement_tracing.h index fc20f041ec02a7..e93ad63b607ade 100644 --- a/paddle/phi/api/profiler/supplement_tracing.h +++ b/paddle/phi/api/profiler/supplement_tracing.h @@ -18,8 +18,8 @@ limitations under the License. */ #include #include -#include "paddle/common/ddim.h" #include "paddle/phi/core/attribute.h" +#include "paddle/phi/core/ddim.h" namespace phi { diff --git a/paddle/phi/core/ddim.h b/paddle/phi/core/ddim.h new file mode 100644 index 00000000000000..1dfd5b67f89eb4 --- /dev/null +++ b/paddle/phi/core/ddim.h @@ -0,0 +1,37 @@ +// 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/common/ddim.h" + +namespace paddle { +namespace framework { +using DDim = common::DDim; +} +} // namespace paddle + +namespace phi { +using DDim = common::DDim; +using common::arity; +using common::contain_unknown_dim; +using common::flatten_to_1d; +using common::flatten_to_2d; +using common::flatten_to_3d; +using common::make_ddim; +using common::product; +using common::slice_ddim; +using common::stride; +using common::stride_numel; +using common::vectorize; +} // namespace phi diff --git a/paddle/phi/core/storage_properties.h b/paddle/phi/core/storage_properties.h index 421f853872cb64..ac64875452bf8f 100644 --- a/paddle/phi/core/storage_properties.h +++ b/paddle/phi/core/storage_properties.h @@ -16,7 +16,7 @@ limitations under the License. */ #include -#include "paddle/common/ddim.h" +#include "paddle/phi/core/ddim.h" #include "paddle/phi/core/utils/type_registry.h" #ifdef PADDLE_WITH_DNNL diff --git a/paddle/phi/core/tensor_base.h b/paddle/phi/core/tensor_base.h index 99318f86cf42b6..71045b12132bcb 100644 --- a/paddle/phi/core/tensor_base.h +++ b/paddle/phi/core/tensor_base.h @@ -14,20 +14,18 @@ limitations under the License. */ #pragma once -#include "paddle/common/ddim.h" #include "paddle/common/layout.h" #include "paddle/phi/common/backend.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/common/place.h" #include "paddle/phi/core/allocator.h" +#include "paddle/phi/core/ddim.h" #include "paddle/phi/core/utils/type_registry.h" namespace phi { class TensorBase { public: - using DDim = phi::DDim; - virtual ~TensorBase() = default; /// \brief Returns the number of elements contained in tensor. diff --git a/paddle/phi/core/tensor_meta.h b/paddle/phi/core/tensor_meta.h index 77f2e2bebb4ec3..4c7c9ace49d321 100644 --- a/paddle/phi/core/tensor_meta.h +++ b/paddle/phi/core/tensor_meta.h @@ -16,10 +16,10 @@ limitations under the License. */ #include -#include "paddle/common/ddim.h" #include "paddle/common/layout.h" #include "paddle/phi/common/backend.h" #include "paddle/phi/common/data_type.h" +#include "paddle/phi/core/ddim.h" #include "paddle/utils/any.h" #include "paddle/utils/optional.h" #include "paddle/utils/test_macros.h" @@ -42,7 +42,6 @@ namespace phi { * 0 2 5 7 10 12 15 20 */ using LoD = std::vector>; -using DDim = phi::DDim; /// \brief The meta data of dense tensor. Take the structure type /// and use all default operations. diff --git a/test/cpp/phi/core/test_ddim.cc b/test/cpp/phi/core/test_ddim.cc index 78d8deebdca3d0..562b4af5a10a11 100644 --- a/test/cpp/phi/core/test_ddim.cc +++ b/test/cpp/phi/core/test_ddim.cc @@ -15,7 +15,7 @@ #include #include "gtest/gtest.h" -#include "paddle/common/ddim.h" +#include "paddle/phi/core/ddim.h" namespace phi { namespace tests {