Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Simplify the logic of sparse_conv #2683

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions mmcv/ops/csrc/pytorch/mlu/sparse_conv_mlu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
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<int64_t>();

// generate empty output
int C = filters.dim() == 4 ? filters.size(3) : filters.size(4);
Expand Down Expand Up @@ -241,12 +237,8 @@ std::vector<torch::Tensor> 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>();
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<int64_t>();

// generate empty input_grad
torch::Tensor input_grad = at::zeros({features.size(0), features.size(1)},
Expand Down