diff --git a/paddle/pten/kernels/empty_kernel.h b/paddle/pten/kernels/empty_kernel.h index 98f7e03d771bee306030a554633f9a2355747154..8a7da8fbd5659fdfb5af73e03e1cce8868b9c726 100644 --- a/paddle/pten/kernels/empty_kernel.h +++ b/paddle/pten/kernels/empty_kernel.h @@ -32,7 +32,7 @@ void EmptyLikeKernel(const Context& dev_ctx, DenseTensor* out); // TODO(chenweihang): the tensor creation method need to be replaced later, // all kernel api call Empty here instead of making tensor self -template +template DenseTensor Empty(const Context& dev_ctx, DenseTensorMeta&& meta) { pten::DenseTensor dense_out( pten::make_intrusive( @@ -43,10 +43,10 @@ DenseTensor Empty(const Context& dev_ctx, DenseTensorMeta&& meta) { template DenseTensor Empty(const Context& dev_ctx) { - return Empty(dev_ctx, - {paddle::experimental::CppTypeToDataType::Type(), - {-1}, - DataLayout::NCHW}); + return Empty(dev_ctx, + {paddle::experimental::CppTypeToDataType::Type(), + {-1}, + DataLayout::NCHW}); } template diff --git a/paddle/pten/kernels/funcs/elementwise_base.h b/paddle/pten/kernels/funcs/elementwise_base.h index 0f26f3d8aa6619b8804ca2782a9b6147f32165f9..21abf82c7b2283da1a82f18c22d31335ee4d3335 100644 --- a/paddle/pten/kernels/funcs/elementwise_base.h +++ b/paddle/pten/kernels/funcs/elementwise_base.h @@ -392,7 +392,7 @@ static inline void GetDoubleGradSafeTensor(const DeviceContext &dev_ctx, *ddx_safe = *ddx; } else { auto meta = pten::DenseTensorMeta(x.dtype(), x.dims(), x.layout()); - *ddx_safe = pten::Empty(dev_ctx, std::move(meta)); + *ddx_safe = pten::Empty(dev_ctx, std::move(meta)); ddx_safe->mutable_data(dev_ctx.GetPlace()); paddle::operators::math::SetConstant set_zero; set_zero(dev_ctx, ddx_safe, static_cast(0)); diff --git a/paddle/pten/kernels/sparse/cpu/sparse_utils_kernel.cc b/paddle/pten/kernels/sparse/cpu/sparse_utils_kernel.cc index a86804e25dcdd644e4b4df1996914b34d20ebfbe..de648f76c1bdef7f83632a42b8d4efcbd3bda24f 100644 --- a/paddle/pten/kernels/sparse/cpu/sparse_utils_kernel.cc +++ b/paddle/pten/kernels/sparse/cpu/sparse_utils_kernel.cc @@ -76,8 +76,10 @@ void DenseToSparseCooKernel(const Context& dev_ctx, {sparse_dim, static_cast(non_zero_num)}, DataLayout::NCHW); DenseTensorMeta values_meta(x.meta().dtype, values_dims, x.meta().layout); - pten::DenseTensor indices = pten::Empty(dev_ctx, std::move(indices_meta)); - pten::DenseTensor values = pten::Empty(dev_ctx, std::move(values_meta)); + pten::DenseTensor indices = + pten::Empty(dev_ctx, std::move(indices_meta)); + pten::DenseTensor values = + pten::Empty(dev_ctx, std::move(values_meta)); int64_t* indices_data = indices.mutable_data(place); T* values_data = values.mutable_data(place); @@ -121,8 +123,10 @@ void SparseCsrToCooKernel(const Context& dev_ctx, DenseTensorMeta indices_meta( DataType::INT64, {sparse_dim, non_zero_num}, DataLayout::NCHW); DenseTensorMeta values_meta(x.dtype(), {non_zero_num}, x.layout()); - pten::DenseTensor indices = pten::Empty(dev_ctx, std::move(indices_meta)); - pten::DenseTensor values = pten::Empty(dev_ctx, std::move(values_meta)); + pten::DenseTensor indices = + pten::Empty(dev_ctx, std::move(indices_meta)); + pten::DenseTensor values = + pten::Empty(dev_ctx, std::move(values_meta)); int64_t* coo_indices = indices.mutable_data(place); int64_t* batch_ptr = x_dims.size() == 2 ? nullptr : coo_indices; int64_t* coo_rows_data = diff --git a/paddle/pten/kernels/sparse/gpu/sparse_utils_kernel.cu b/paddle/pten/kernels/sparse/gpu/sparse_utils_kernel.cu index cd3124bd02fcbedc0052c37c2cefe10b4d73a747..cb8e30753107e2dbfc08ad1fa82b4dd4aea417e7 100644 --- a/paddle/pten/kernels/sparse/gpu/sparse_utils_kernel.cu +++ b/paddle/pten/kernels/sparse/gpu/sparse_utils_kernel.cu @@ -111,12 +111,14 @@ void DenseToSparseCooKernel(const Context& dev_ctx, const int cols = dims_2d[1]; auto nums_meta = pten::DenseTensorMeta(DataType::INT32, {1}, pten::DataLayout::NCHW); - DenseTensor nums = pten::Empty(dev_ctx, std::move(nums_meta)); + DenseTensor nums = + pten::Empty(dev_ctx, std::move(nums_meta)); auto x_dims_meta = pten::DenseTensorMeta(DataType::INT64, {static_cast(x_dims.size())}, pten::DataLayout::NCHW); - DenseTensor d_x_dims = pten::Empty(dev_ctx, std::move(x_dims_meta)); + DenseTensor d_x_dims = + pten::Empty(dev_ctx, std::move(x_dims_meta)); const auto place = dev_ctx.GetPlace(); @@ -134,7 +136,8 @@ void DenseToSparseCooKernel(const Context& dev_ctx, auto temp_indexs_meta = pten::DenseTensorMeta(DataType::INT32, {rows}, pten::DataLayout::NCHW); - DenseTensor temp_indexs = pten::Empty(dev_ctx, std::move(temp_indexs_meta)); + DenseTensor temp_indexs = + pten::Empty(dev_ctx, std::move(temp_indexs_meta)); int* temp_indexs_ptr = temp_indexs.mutable_data(place); GetNonZeroNums<<>>( x_data, rows, cols, nums_ptr, temp_indexs_ptr); @@ -266,9 +269,11 @@ void SparseCsrToCooKernel(const Context& dev_ctx, DataType::INT64, {sparse_dim, non_zero_num}, DataLayout::NCHW); DenseTensorMeta values_meta(x.dtype(), {non_zero_num}, x.layout()); DenseTensorMeta offsets_meta(DataType::INT32, {batchs}, DataLayout::NCHW); - DenseTensor indices = pten::Empty(dev_ctx, std::move(indices_meta)); - DenseTensor values = pten::Empty(dev_ctx, std::move(values_meta)); - DenseTensor offsets = pten::Empty(dev_ctx, std::move(offsets_meta)); + DenseTensor indices = + pten::Empty(dev_ctx, std::move(indices_meta)); + DenseTensor values = pten::Empty(dev_ctx, std::move(values_meta)); + DenseTensor offsets = + pten::Empty(dev_ctx, std::move(offsets_meta)); int64_t* coo_indices = indices.mutable_data(place); int64_t* batch_ptr = x_dims.size() == 2 ? nullptr : coo_indices; int64_t* coo_rows_data =