@@ -25,9 +25,9 @@ namespace custom_kernel {
2525 */
2626template <typename Context>
2727inline void TensorCopy (const Context& dev_ctx,
28- const phi:: DenseTensor& src,
28+ const DenseTensor& src,
2929 bool blocking,
30- phi:: DenseTensor* dst,
30+ DenseTensor* dst,
3131 const phi::Place& dst_place = phi::CustomPlace()) {
3232 dev_ctx.Wait ();
3333 auto * src_ptr = src.data ();
@@ -103,7 +103,7 @@ template <typename T>
103103inline void TensorFromVector (const phi::CustomContext& ctx,
104104 const std::vector<T>& src,
105105 const phi::CustomContext& dev_ctx,
106- phi:: DenseTensor* dst) {
106+ DenseTensor* dst) {
107107 auto dst_place = dev_ctx.GetPlace ();
108108 C_Device_st device{dst_place.GetDeviceId ()};
109109 auto src_ptr = static_cast <const void *>(src.data ());
@@ -128,7 +128,7 @@ template <>
128128inline void TensorFromVector<bool >(const phi::CustomContext& ctx,
129129 const std::vector<bool >& src,
130130 const phi::CustomContext& dev_ctx,
131- phi:: DenseTensor* dst) {
131+ DenseTensor* dst) {
132132 // vector<bool> has no data() member, use array instead.
133133 // See details:
134134 // https://stackoverflow.com/questions/46115669/why-does-stdvectorbool-have-no-data/46115714
@@ -166,7 +166,7 @@ template <typename T>
166166inline void TensorFromVector (const phi::CustomContext& ctx,
167167 const std::vector<T>& src,
168168 const phi::CPUContext& dev_ctx,
169- phi:: DenseTensor* dst) {
169+ DenseTensor* dst) {
170170 auto dst_place = dev_ctx.GetPlace ();
171171 C_Device_st device{dst_place.GetDeviceId ()};
172172 auto src_ptr = static_cast <const void *>(src.data ());
@@ -191,7 +191,7 @@ template <>
191191inline void TensorFromVector<bool >(const phi::CustomContext& ctx,
192192 const std::vector<bool >& src,
193193 const phi::CPUContext& dev_ctx,
194- phi:: DenseTensor* dst) {
194+ DenseTensor* dst) {
195195 auto dst_place = dev_ctx.GetPlace ();
196196 PADDLE_THROW (phi::errors::Unimplemented (
197197 " TensorFromVector on %s is not supported." , dst_place));
@@ -202,7 +202,7 @@ void TensorFromArray(const phi::CustomContext& ctx,
202202 const T* src,
203203 const size_t & array_size,
204204 const phi::CustomContext& dev_ctx,
205- phi:: DenseTensor* dst) {
205+ DenseTensor* dst) {
206206 auto dst_place = dev_ctx.GetPlace ();
207207 C_Device_st device{dst_place.GetDeviceId ()};
208208 auto src_ptr = static_cast <const void *>(src);
@@ -227,7 +227,7 @@ void TensorFromArray(const phi::CustomContext& ctx,
227227 */
228228template <typename T>
229229inline void TensorToVector (const phi::CustomContext& ctx,
230- const phi:: DenseTensor& src,
230+ const DenseTensor& src,
231231 const phi::CustomContext& dev_ctx,
232232 std::vector<T>* dst) {
233233 auto src_ptr = static_cast <const void *>(src.data <T>());
@@ -251,7 +251,7 @@ inline void TensorToVector(const phi::CustomContext& ctx,
251251
252252template <>
253253inline void TensorToVector<bool >(const phi::CustomContext& ctx,
254- const phi:: DenseTensor& src,
254+ const DenseTensor& src,
255255 const phi::CustomContext& dev_ctx,
256256 std::vector<bool >* dst) {
257257 auto src_ptr = static_cast <const void *>(src.data <bool >());
@@ -359,11 +359,10 @@ inline void ExtractNCDWH(const phi::DDim& dims,
359359
360360template <typename T>
361361inline std::vector<T> get_new_data_from_tensor (
362- const phi::CustomContext& dev_ctx,
363- const phi::DenseTensor* new_data_tensor) {
362+ const phi::CustomContext& dev_ctx, const DenseTensor* new_data_tensor) {
364363 std::vector<T> vec_new_data;
365364 auto place = new_data_tensor->place ();
366- phi:: DenseTensor cpu_starts_tensor;
365+ DenseTensor cpu_starts_tensor;
367366 if (place.GetType () == phi::AllocationType::CUSTOM) {
368367 // if tensor on CUSTOM place, do memcpy to host
369368 cpu_starts_tensor.Resize (new_data_tensor->dims ());
@@ -381,22 +380,21 @@ inline std::vector<T> get_new_data_from_tensor(
381380}
382381
383382template <typename T>
384- inline phi::DenseTensor ReshapeToMatrix (const phi::DenseTensor& src,
385- T num_col_dims) {
383+ inline DenseTensor ReshapeToMatrix (const DenseTensor& src, T num_col_dims) {
386384 int rank = src.dims ().size ();
387385 PADDLE_ENFORCE_GE (
388386 rank,
389387 2 ,
390388 phi::errors::InvalidArgument (
391389 " 'ReshapeToMatrix()' is only used for flatten high rank "
392- " tensors to matrixs. The dimensions of phi:: DenseTensor must be "
390+ " tensors to matrixs. The dimensions of DenseTensor must be "
393391 " greater or equal than 2. "
394- " But received dimensions of phi:: DenseTensor is %d" ,
392+ " But received dimensions of DenseTensor is %d" ,
395393 rank));
396394 if (rank == 2 ) {
397395 return src;
398396 }
399- phi:: DenseTensor res;
397+ DenseTensor res;
400398 res = src;
401399 res.Resize (phi::flatten_to_2d (src.dims (), num_col_dims));
402400 return res;
0 commit comments