未验证 提交 14049ae5 编写于 作者: C chentianyu03 提交者: GitHub

[pten] add CI check for using DenseTensor::mutable_data() in pten directions (#39467)

上级 02938b3d
...@@ -162,6 +162,11 @@ class DenseTensor : public TensorBase, ...@@ -162,6 +162,11 @@ class DenseTensor : public TensorBase,
/// \return The const data pointer value of raw type. /// \return The const data pointer value of raw type.
const void* data() const; const void* data() const;
template <typename T>
T* data();
void* data();
private: private:
friend class DenseTensorUtils; friend class DenseTensorUtils;
......
...@@ -53,11 +53,6 @@ DenseTensor(intrusive_ptr<Storage> storage, DenseTensorMeta&& meta); ...@@ -53,11 +53,6 @@ DenseTensor(intrusive_ptr<Storage> storage, DenseTensorMeta&& meta);
inline bool IsInitialized() const { return holder_ != nullptr; } inline bool IsInitialized() const { return holder_ != nullptr; }
template <typename T>
T* data();
void* data();
template <typename T> template <typename T>
T* mutable_data(const paddle::platform::Place& place, T* mutable_data(const paddle::platform::Place& place,
size_t requested_size = 0); size_t requested_size = 0);
......
...@@ -262,6 +262,17 @@ if [ "${PTEN_INCLUDE_FLUID_FILES}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then ...@@ -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" 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 check_approval 1 chenwhql MingMingShangTian YuanRisheng zyfncg
fi 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_CHANGE_FILES=`git diff --numstat upstream/$BRANCH | awk '{print $3}' | grep ".py"`
ALL_OPTEST_BAN_DYGRAPH_MESSAGE="" ALL_OPTEST_BAN_DYGRAPH_MESSAGE=""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册