From 2f87c2a952254b009d508132aa8bef0cc3b17a88 Mon Sep 17 00:00:00 2001 From: duzekun Date: Tue, 21 Mar 2023 15:56:04 +0800 Subject: [PATCH] [Feature] Update sparse_conv mlu code style --- mmcv/ops/csrc/pytorch/mlu/sparse_conv_mlu.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/mmcv/ops/csrc/pytorch/mlu/sparse_conv_mlu.cpp b/mmcv/ops/csrc/pytorch/mlu/sparse_conv_mlu.cpp index 165aae1715..19cdb944fe 100644 --- a/mmcv/ops/csrc/pytorch/mlu/sparse_conv_mlu.cpp +++ b/mmcv/ops/csrc/pytorch/mlu/sparse_conv_mlu.cpp @@ -147,12 +147,8 @@ torch::Tensor IndiceConvForwardMLUKernelLauncher( torch::Tensor indiceNum, int64_t numActOut, int64_t _inverse, int64_t _subM) { auto indice_num_cpu = indiceNum.to({torch::kCPU}); - auto indice_num_cpu_64 = indice_num_cpu.data_ptr(); - int indice_num_len = indiceNum.numel(); - int64_t indice_num[indice_num_len]; - for (int i = 0; i < indice_num_len; ++i) { - indice_num[i] = (int64_t)(((int *)indice_num_cpu_64)[i]); - } + auto indice_num_cpu_64 = indice_num_cpu.to(torch::kInt64); + auto indice_num = indice_num_cpu_64.data_ptr(); // generate empty output int C = filters.dim() == 4 ? filters.size(3) : filters.size(4); @@ -241,12 +237,8 @@ std::vector IndiceConvBackwardMLUKernelLauncher( torch::Tensor indicePairs, torch::Tensor indiceNum, int64_t _inverse, int64_t _subM) { auto indice_num_cpu = indiceNum.to({torch::kCPU}); - auto indice_num_cpu_64 = indice_num_cpu.data_ptr(); - int indice_num_len = indiceNum.numel(); - int64_t indice_num[indice_num_len]; - for (int i = 0; i < indice_num_len; ++i) { - indice_num[i] = (int64_t)(((int *)(indice_num_cpu_64))[i]); - } + auto indice_num_cpu_64 = indice_num_cpu.to(torch::kInt64); + auto indice_num = indice_num_cpu_64.data_ptr(); // generate empty input_grad torch::Tensor input_grad = at::zeros({features.size(0), features.size(1)},