Skip to content

Commit

Permalink
Alias DDim in phi (#59671)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbopd authored Dec 5, 2023
1 parent b162d7e commit d9b7760
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 32 deletions.
2 changes: 1 addition & 1 deletion paddle/cinn/hlir/framework/pir/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct CompatibleInfo {
static OpPatternKind OpKind(const ::pir::Operation& op);
};

std::vector<int64_t> GetBroadcastAxis(const phi::DDim& in_shape,
std::vector<int64_t> GetBroadcastAxis(const ::common::DDim& in_shape,
const std::vector<int64_t>& out_shape);

} // namespace pir
Expand Down
22 changes: 1 addition & 21 deletions paddle/common/ddim.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <initializer_list>
#include <numeric>
Expand Down Expand Up @@ -234,27 +235,6 @@ 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<std::vector<size_t>>;
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pir/transforms/transform_general_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pybind/pir.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#pragma once

#include <pybind11/pybind11.h>
#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 {
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/api/profiler/supplement_tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ limitations under the License. */
#include <string>
#include <utility>

#include "paddle/common/ddim.h"
#include "paddle/phi/core/attribute.h"
#include "paddle/phi/core/ddim.h"

namespace phi {

Expand Down
37 changes: 37 additions & 0 deletions paddle/phi/core/ddim.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion paddle/phi/core/storage_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License. */

#include <memory>

#include "paddle/common/ddim.h"
#include "paddle/phi/core/ddim.h"
#include "paddle/phi/core/utils/type_registry.h"

#ifdef PADDLE_WITH_DNNL
Expand Down
4 changes: 1 addition & 3 deletions paddle/phi/core/tensor_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions paddle/phi/core/tensor_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ limitations under the License. */

#include <vector>

#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"
Expand All @@ -42,7 +42,6 @@ namespace phi {
* 0 2 5 7 10 12 15 20
*/
using LoD = std::vector<std::vector<size_t>>;
using DDim = phi::DDim;

/// \brief The meta data of dense tensor. Take the structure type
/// and use all default operations.
Expand Down
2 changes: 1 addition & 1 deletion test/cpp/phi/core/test_ddim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <sstream>

#include "gtest/gtest.h"
#include "paddle/common/ddim.h"
#include "paddle/phi/core/ddim.h"

namespace phi {
namespace tests {
Expand Down

0 comments on commit d9b7760

Please sign in to comment.