Skip to content

Commit 503569a

Browse files
author
zhangkaihuo
authoredMay 6, 2022
fix conv3d backward (#42502)
1 parent d73eb38 commit 503569a

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed
 

‎paddle/phi/kernels/sparse/gpu/convolution_grad_kernel.cu

+8-27
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ limitations under the License. */
2222
#include "paddle/phi/kernels/copy_kernel.h"
2323
#include "paddle/phi/kernels/funcs/blas/blas.h"
2424
#include "paddle/phi/kernels/funcs/math_function.h"
25-
#include "paddle/phi/kernels/funcs/sparse/scatter.cu.h"
25+
#include "paddle/phi/kernels/funcs/scatter.cu.h"
2626
#include "paddle/phi/kernels/sparse/convolution_grad_kernel.h"
2727
#include "paddle/phi/kernels/sparse/gpu/convolution.cu.h"
2828

@@ -203,38 +203,19 @@ void Conv3dGradGPUKernel(const GPUContext& dev_ctx,
203203
}
204204

205205
// 4. scatter
206-
// x_grad->ResizeAndAllocate(x.non_zero_elements().dims());
207-
DenseTensorMeta index_meta(DataType::INT32, {rulebook_len}, DataLayout::NCHW);
208-
DenseTensor out_index = phi::Empty(dev_ctx, std::move(index_meta));
209-
DenseTensor unique_key = phi::Empty(
210-
dev_ctx,
211-
DenseTensorMeta(paddle::experimental::CppTypeToDataType<IntT>::Type(),
212-
{rulebook_len},
213-
DataLayout::NCHW));
214-
DenseTensor unique_value = phi::Empty(dev_ctx, std::move(index_meta));
215-
216-
SortedAndUniqueIndex<GPUContext, IntT>(dev_ctx,
217-
rulebook_ptr + rulebook_len,
218-
rulebook_len,
219-
&out_index,
220-
&unique_key,
221-
&unique_value);
222-
223206
config = phi::backends::gpu::GetGpuLaunchConfig1D(
224207
dev_ctx, rulebook_len * in_channels, 1);
225208

226-
phi::funcs::sparse::ScatterKernel<T><<<config.block_per_grid.x,
227-
config.thread_per_block.x,
228-
0,
229-
dev_ctx.stream()>>>(
209+
phi::funcs::ScatterCUDAKernel<<<config.block_per_grid,
210+
config.thread_per_block,
211+
0,
212+
dev_ctx.stream()>>>(
230213
d_x_features_ptr,
231-
unique_value.data<int>(),
232-
out_index.data<int>(),
233-
x.nnz(),
214+
rulebook_ptr + rulebook_len,
215+
x_grad_values_ptr,
234216
rulebook_len,
235217
in_channels,
236-
x_grad_values_ptr,
237-
subm);
218+
false);
238219
}
239220

240221
template <typename T, typename Context>

0 commit comments

Comments
 (0)
Please sign in to comment.