diff --git a/paddle/pten/core/dense_tensor.h b/paddle/pten/core/dense_tensor.h index ef8520e29c3b2fc1cdce0c7881d7c1e1aa653f1a..44232930e5f0d7b8e150a12d054b669c765dc0f8 100644 --- a/paddle/pten/core/dense_tensor.h +++ b/paddle/pten/core/dense_tensor.h @@ -162,6 +162,11 @@ class DenseTensor : public TensorBase, /// \return The const data pointer value of raw type. const void* data() const; + template + T* data(); + + void* data(); + private: friend class DenseTensorUtils; diff --git a/paddle/pten/core/dense_tensor.inl b/paddle/pten/core/dense_tensor.inl index d5d207aba40c2f6299c83dba2d24128d3e1eb7cc..4df6b2556a8aff6af657d183d2128ea4483482f2 100644 --- a/paddle/pten/core/dense_tensor.inl +++ b/paddle/pten/core/dense_tensor.inl @@ -53,11 +53,6 @@ DenseTensor(intrusive_ptr storage, DenseTensorMeta&& meta); inline bool IsInitialized() const { return holder_ != nullptr; } -template -T* data(); - -void* data(); - template T* mutable_data(const paddle::platform::Place& place, size_t requested_size = 0); diff --git a/tools/check_file_diff_approvals.sh b/tools/check_file_diff_approvals.sh index eb58764f7fce3aa6a77126c84c54bf4c61b7487b..4fd4e809cacbec0e65223a200f56b26c7f34e6b6 100644 --- a/tools/check_file_diff_approvals.sh +++ b/tools/check_file_diff_approvals.sh @@ -262,6 +262,17 @@ if [ "${PTEN_INCLUDE_FLUID_FILES}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then echo_line="You must have one RD (chenwhql, MingMingShangTian, YuanRisheng or zyfncg) approval for the including paddle/fluid header in paddle/pten files(${PTEN_INCLUDE_FLUID_FILES}).\n" check_approval 1 chenwhql MingMingShangTian YuanRisheng zyfncg fi +PTEN_USE_MUTABLE_DATA_FILES="" +for CHANGE_FILE in ${HAS_MODIFIED_PTEN_FILES}; do + PTEN_DIR_ADDED_LINES=`git diff -U0 upstream/$BRANCH -- ${PADDLE_ROOT}/${CHANGE_FILE} | grep "^+" | grep -w "mutable_data" || true` + if [ "${PTEN_DIR_ADDED_LINES}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then + PTEN_USE_MUTABLE_DATA_FILES="${PTEN_USE_MUTABLE_DATA_FILES} ${CHANGE_FILE}" + fi +done +if [ "${PTEN_USE_MUTABLE_DATA_FILES}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then + echo_line="You can not use the DenseTensor::mutable_data() method in paddle/pten files(${PTEN_USE_MUTABLE_DATA_FILES}). If you want to alloc memory, use pten::DeviceContext::Alloc() or pten::DeviceContext::HostAlloc() instead and if you want to get mutable data, use DenseTensor::data(). If you have any questions, you can have one RD (chenwhql, Shixiaowei02, MingMingShangTian, YuanRisheng or zyfncg) review and approve.\n" + check_approval 1 chenwhql Shixiaowei02 MingMingShangTian YuanRisheng zyfncg +fi ALL_CHANGE_FILES=`git diff --numstat upstream/$BRANCH | awk '{print $3}' | grep ".py"` ALL_OPTEST_BAN_DYGRAPH_MESSAGE=""