| 195 | |
| 196 | template <typename T> |
| 197 | T *Tensor::mutable_data() { |
| 198 | LOG_FIRST_N(WARNING, 1) |
| 199 | << "Allocating memory through `mutable_data` method is " |
| 200 | "deprecated since version 2.3, and `mutable_data` method " |
| 201 | "will be removed in version 2.4! Please use " |
| 202 | "`paddle::empty/full` method to create a new " |
| 203 | "Tensor with allocated memory, and use data<T>() method " |
| 204 | "to get the memory pointer of tensor instead. " |
| 205 | "Reason: When calling `mutable_data` to allocate memory, " |
| 206 | "the place, datatype, and data layout of tensor may be in " |
| 207 | "an illegal state."; |
| 208 | if (is_dense_tensor()) { |
| 209 | return static_cast<phi::DenseTensor *>(impl_.get()) |
| 210 | ->mutable_data<T>(place()); |
| 211 | } |
| 212 | return nullptr; |
| 213 | } |
| 214 | |
| 215 | template PADDLE_API bool *Tensor::mutable_data<bool>(); |
| 216 | template PADDLE_API int8_t *Tensor::mutable_data<int8_t>(); |