Skip to content

Commit 718bc4b

Browse files
committed
fix torch
1 parent 1157e18 commit 718bc4b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,20 @@ void softmax_focal_loss_forward_npu(Tensor input, Tensor target, Tensor weight,
9999
c10::SmallVector<int64_t, 2> offsets = {0, 0};
100100
c10::SmallVector<int64_t, 2> sizes = {n_batch, 1};
101101
at::IntArrayRef offset = at::IntArrayRef(offsets);
102-
at::IntArrayRef size = at::IntArrayRef(sizes);
103-
104-
c10::SmallVector<int64_t, SIZE> output_size = convert_array_to_vector(size);
102+
at::IntArrayRef size_array = at::IntArrayRef(sizes);
103+
c10::SmallVector<int64_t, N> output_size;
104+
for (uint64_t i = 0; i < size_array.size(); i++) {
105+
output_size.emplace_back(size_array[i]);
106+
}
105107
at::Tensor result = at::empty(output_size, op_output.options());
106108
c10::SmallVector<int64_t, N> offsetVec = array_to_small_vector(offset);
107-
c10::SmallVector<int64_t, N> sizeVec = array_to_small_vector(size);
108-
OpCommand cmd;
109+
c10::SmallVector<int64_t, N> sizeVec = array_to_small_vector(size_array);
109110
cmd.Name("Slice")
110-
.Input(self)
111+
.Input(op_output)
111112
.Input(offsetVec)
112113
.Input(sizeVec)
113-
.Output(result)
114+
.Output(output)
114115
.Run();
115-
return result;
116116
}
117117

118118
void softmax_focal_loss_forward_impl(Tensor input, Tensor target, Tensor weight,

0 commit comments

Comments
 (0)