sort.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include "ultra_infer/core/fd_tensor.h"
  16. namespace ultra_infer {
  17. namespace function {
  18. /**
  19. * @brief Performs sorting on the input tensor along the given axis and outputs
  20. * two tensors, Output(Out) and Output(Indices). They reserve the same
  21. * shape with Input(X), and Output(Out) represents the sorted tensor
  22. * while Output(Indices) gives the sorted order along the given axis
  23. * Attr(axis).
  24. * @param x The input of sort
  25. * @param out The sorted tensor of sort op, with the same shape as
  26. * x
  27. * @param indices The indices of a tensor giving the sorted order, with
  28. * the same shape as x
  29. * @param axis The axis along which to sort the tensor.
  30. * When axis < 0, the actual axis will be the |axis|'th
  31. * counting backwards
  32. * @param descending The descending attribute is a flag to tell
  33. * algorithm how to sort the input data.
  34. * If descending is true, will sort by descending order,
  35. * else if false, sort by ascending order
  36. * @param indices_type The data type of indices, default to int64
  37. */
  38. ULTRAINFER_DECL void Sort(const FDTensor &x, FDTensor *out, FDTensor *indices,
  39. int axis = 0, bool descending = false,
  40. FDDataType indices_type = FDDataType::INT64);
  41. } // namespace function
  42. } // namespace ultra_infer