Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias DDim in phi #59671

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
25 changes: 3 additions & 22 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,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<std::vector<size_t>>;
} // namespace pir

namespace std {
template <>
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