Skip to content
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
12 changes: 7 additions & 5 deletions fastdeploy/function/sort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ void SortKernel(const FDTensor& x, FDTensor* out, FDTensor* indices,
axis = (axis < 0) ? (rank + axis) : axis;
// Do full sort
if (axis == -1 || axis + 1 == rank) {
const int64_t input_width = input_shape[rank - 1];
const int64_t input_height = x.Numel() / input_width;
int64_t numel = x.Numel();
int64_t input_width = input_shape[axis];
int64_t input_height = numel / input_width;
FD_VISIT_INT_TYPES(indices_type, "FullSort", ([&] {
FullSort<T, data_t>(input_height, input_width, rank,
&x, out, indices, descending);
Expand All @@ -93,8 +94,9 @@ void SortKernel(const FDTensor& x, FDTensor* out, FDTensor* indices,

FDTensor trans_inp;
Transpose(x, &trans_inp, trans);
const int64_t input_width = input_shape[axis];
const int64_t input_height = x.Numel() / input_width;
int64_t numel = x.Numel();
int64_t input_width = input_shape[axis];
int64_t input_height = numel / input_width;
FD_VISIT_INT_TYPES(indices_type, "FullSort", ([&] {
FullSort<T, data_t>(input_height, input_width, rank,
&trans_inp, out, indices,
Expand All @@ -115,4 +117,4 @@ void Sort(const FDTensor& x, FDTensor* out, FDTensor* indices, int axis,
}

} // namespace function
} // namespace fastdeploy
} // namespace fastdeploy