Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
efd5dba
add kernel dialect
phlrain Jun 7, 2023
cdb0f51
change DenseTensorTypeStorage to DenseTensorType
phlrain Jun 7, 2023
8d5e365
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 7, 2023
406bc1c
add test case`
phlrain Jun 8, 2023
bfc101e
add first pd_op to kernel dialect
phlrain Jun 8, 2023
1c79bb3
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 8, 2023
40a5366
lower pd op to kernel dialect
phlrain Jun 8, 2023
4e0cca9
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 8, 2023
d42faeb
update
phlrain Jun 9, 2023
1b6a177
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 9, 2023
b7899b7
update
phlrain Jun 9, 2023
1dd62a1
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 9, 2023
615644f
remove useless code
phlrain Jun 9, 2023
8bf22ec
add attrite print test
phlrain Jun 10, 2023
2b30fcd
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 10, 2023
62553cd
fix bug
phlrain Jun 10, 2023
5f25a1b
update
phlrain Jun 12, 2023
c3955c2
update
phlrain Jun 12, 2023
d77d201
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 12, 2023
8cee11d
update
phlrain Jun 12, 2023
758f7d2
update
phlrain Jun 13, 2023
19ff366
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 13, 2023
442406a
polish code
phlrain Jun 13, 2023
9f08c8f
fix bug
phlrain Jun 13, 2023
9534bc6
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 13, 2023
801b3af
polish code and add python test
phlrain Jun 13, 2023
c81e3d9
add test
phlrain Jun 13, 2023
09dd11c
fix test error
phlrain Jun 13, 2023
5cf4cfe
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 13, 2023
da1d4e0
add env flag
phlrain Jun 13, 2023
140ae48
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 13, 2023
30e4fae
fix bug
phlrain Jun 14, 2023
8529a54
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 14, 2023
06c9637
revert test env
phlrain Jun 14, 2023
907b89c
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 14, 2023
cc94c6f
change cc_test_old to cc_test
phlrain Jun 14, 2023
a81bfee
Merge commit 'refs/pull/54570/head' of https://github.com/PaddlePaddl…
phlrain Jun 14, 2023
f467dd4
fix build_static bug
phlrain Jun 14, 2023
a3dc4be
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 14, 2023
a619313
fix type test error
phlrain Jun 14, 2023
e3e8ee6
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 14, 2023
79da0a4
udpate cmake
phlrain Jun 14, 2023
1711c49
disable test in windows
phlrain Jun 14, 2023
f276a93
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 14, 2023
ff1f102
Merge commit 'refs/pull/54570/head' of https://github.com/PaddlePaddl…
phlrain Jun 14, 2023
61d019e
update
phlrain Jun 15, 2023
8f469fd
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 15, 2023
b6006e8
update
phlrain Jun 16, 2023
bdbbd7c
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 16, 2023
664390f
fix bug
phlrain Jun 16, 2023
93136d5
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 16, 2023
0057407
split file
phlrain Jun 18, 2023
b20441d
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 19, 2023
8e0831e
fix conflict
phlrain Jun 19, 2023
9c8525d
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 19, 2023
40f8602
polish code and fix conflict
phlrain Jun 19, 2023
a432785
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 19, 2023
515c2ed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Jun 19, 2023
4ceb650
polish code
phlrain Jun 19, 2023
56ca9a9
fix bug
phlrain Jun 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ void BuildOpFuncList(

auto op_name = attr_map.at("op_name").dyn_cast<::ir::StrAttribute>().data();

if (op_name == "pd.fetch") {
if (op_name == "pd.fetch" || op_name == "builtin.combine") {
VLOG(6) << "skip process pd.fetch op";
continue;
}
Expand Down
89 changes: 89 additions & 0 deletions paddle/fluid/framework/phi_tensor_base_vector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// 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 <string>
#include <unordered_map>
#include <vector>
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/extended_tensor.h"

namespace paddle {
namespace framework {

template <typename T>
struct PhiVectorType;

template <typename T>
class PhiVector : public phi::ExtendedTensor,
public phi::TypeInfoTraits<phi::TensorBase, PhiVector<T>> {
public:
PhiVector() = default;

explicit PhiVector(const std::vector<T>& init_data) : data_(init_data) {}

PhiVector(PhiVector&& other) = default;

PhiVector(const PhiVector& other) = default;

PhiVector& operator=(const PhiVector& other) = default;

PhiVector& operator=(const std::vector<T>& other) {
data_ = other;
return *this;
}

PhiVector& operator=(PhiVector&& other) = default;

/// \brief Destroy the PhiVector and release exclusive resources.
virtual ~PhiVector() = default;

public:
/// \brief Returns the name of the class for type traits.
/// \return The name of the class.
static const char* name() { return PhiVectorType<T>().type_name; }

size_t size() const { return data_.size(); }

void resize(size_t size) { data_.resize(size); }

void clear() { data_.clear(); }

void emplace_back(const T& feed_data) { data_.emplace_back(feed_data); }

const T& operator[](size_t index) const { return data_[index]; }

T& operator[](size_t index) { return data_[index]; }

T& at(size_t index) { return data_.at(index); }

const T& at(size_t index) const { return data_.at(index); }

typename std::vector<T>::iterator begin() { return data_.begin(); }

typename std::vector<T>::const_iterator begin() const {
return data_.begin();
}

typename std::vector<T>::iterator end() { return data_.end(); }

typename std::vector<T>::const_iterator end() const { return data_.end(); }

private:
std::vector<T> data_;
};

} // namespace framework
} // namespace paddle
64 changes: 2 additions & 62 deletions paddle/fluid/framework/string_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ limitations under the License. */
#include <string>
#include <unordered_map>
#include <vector>
#include "paddle/fluid/framework/phi_tensor_base_vector.h"
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/extended_tensor.h"

namespace paddle {
Expand Down Expand Up @@ -102,73 +104,11 @@ class Vocab : public phi::ExtendedTensor,
// Kernel. It can be used when you define a non-tensor type that needs to be
// stored in a vector as PHI kernel argument.

template <typename T>
struct PhiVectorType;

template <>
struct PhiVectorType<std::string> {
const char* type_name = "PhiVectorString";
};

template <typename T>
class PhiVector : public phi::ExtendedTensor,
public phi::TypeInfoTraits<phi::TensorBase, PhiVector<T>> {
public:
PhiVector() = default;

explicit PhiVector(const std::vector<T>& init_data) : data_(init_data) {}

PhiVector(PhiVector&& other) = default;

PhiVector(const PhiVector& other) = default;

PhiVector& operator=(const PhiVector& other) = default;

PhiVector& operator=(const std::vector<T>& other) {
data_ = other;
return *this;
}

PhiVector& operator=(PhiVector&& other) = default;

/// \brief Destroy the PhiVector and release exclusive resources.
virtual ~PhiVector() = default;

public:
/// \brief Returns the name of the class for type traits.
/// \return The name of the class.
static const char* name() { return PhiVectorType<T>().type_name; }

size_t size() const { return data_.size(); }

void resize(size_t size) { data_.resize(size); }

void clear() { data_.clear(); }

void emplace_back(const T& feed_data) { data_.emplace_back(feed_data); }

const T& operator[](size_t index) const { return data_[index]; }

T& operator[](size_t index) { return data_[index]; }

T& at(size_t index) { return data_.at(index); }

const T& at(size_t index) const { return data_.at(index); }

typename std::vector<T>::iterator begin() { return data_.begin(); }

typename std::vector<T>::const_iterator begin() const {
return data_.begin();
}

typename std::vector<T>::iterator end() { return data_.end(); }

typename std::vector<T>::const_iterator end() const { return data_.end(); }

private:
std::vector<T> data_;
};

using String = std::string;
using Strings = PhiVector<std::string>;

Expand Down
30 changes: 30 additions & 0 deletions paddle/fluid/framework/tensor_ref_array.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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/fluid/framework/phi_tensor_base_vector.h"

namespace paddle {
namespace framework {

template <>
struct PhiVectorType<const phi::DenseTensor*> {
const char* type_name = "PhiTensorRefArray";
};

using TensorRefArray = PhiVector<const phi::DenseTensor*>;

} // namespace framework
} // namespace paddle
2 changes: 2 additions & 0 deletions paddle/fluid/framework/type_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ template class TypeInfoTraits<phi::TensorBase, paddle::framework::Strings>;
template class TypeInfoTraits<phi::TensorBase, paddle::framework::FeedList>;
template class TypeInfoTraits<phi::TensorBase, egr::VariableCompatTensor>;
template class TypeInfoTraits<phi::TensorBase, paddle::prim::DescTensor>;
template class TypeInfoTraits<phi::TensorBase,
paddle::framework::TensorRefArray>;

} // namespace phi
4 changes: 3 additions & 1 deletion paddle/fluid/framework/var_type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "paddle/fluid/framework/lod_tensor_array.h"
#include "paddle/fluid/framework/raw_tensor.h"
#include "paddle/fluid/framework/string_array.h"
#include "paddle/fluid/framework/tensor_ref_array.h"
#include "paddle/fluid/platform/place.h"
#ifdef PADDLE_WITH_CUDA
#include <cudnn.h>
Expand Down Expand Up @@ -210,7 +211,8 @@ using VarTypeRegistry = detail::VarTypeRegistryImpl<
std::vector<int>,
std::vector<float>,
std::vector<std::string>,
RawTensor>;
RawTensor,
TensorRefArray>;
template <typename T>
struct VarTypeTrait {
static_assert(VarTypeRegistry::IsRegistered<T>(), "Must be registered type");
Expand Down
Loading