math.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. /** Calculates the sqrt of the given input Tensor, element-wise. Only for float
  19. type FDTensor
  20. @param x The input tensor.
  21. @param out The output tensor which stores the result.
  22. */
  23. ULTRAINFER_DECL void Sqrt(const FDTensor &x, FDTensor *out);
  24. /** Calculates the natural log of the given input Tensor, element-wise. Only for
  25. float type FDTensor
  26. @param x The input tensor.
  27. @param out The output tensor which stores the result.
  28. */
  29. ULTRAINFER_DECL void Log(const FDTensor &x, FDTensor *out);
  30. /** Rounds the values in the input to the nearest integer value, element-wise.
  31. Only for float type FDTensor
  32. @param x The input tensor.
  33. @param out The output tensor which stores the result.
  34. */
  35. ULTRAINFER_DECL void Round(const FDTensor &x, FDTensor *out);
  36. /** Computes exp of x element-wise with a natural number e as the base,
  37. element-wise. Only for float type FDTensor
  38. @param x The input tensor.
  39. @param out The output tensor which stores the result.
  40. */
  41. ULTRAINFER_DECL void Exp(const FDTensor &x, FDTensor *out);
  42. /** This operator is used to perform elementwise abs for input X. Only for float
  43. type FDTensor
  44. @param x The input tensor.
  45. @param out The output tensor which stores the result.
  46. */
  47. ULTRAINFER_DECL void Abs(const FDTensor &x, FDTensor *out);
  48. /** Computes ceil of x element-wise. Only for float type FDTensor
  49. @param x The input tensor.
  50. @param out The output tensor which stores the result.
  51. */
  52. ULTRAINFER_DECL void Ceil(const FDTensor &x, FDTensor *out);
  53. /** Computes floor of x element-wise. Only for float type FDTensor
  54. @param x The input tensor.
  55. @param out The output tensor which stores the result.
  56. */
  57. ULTRAINFER_DECL void Floor(const FDTensor &x, FDTensor *out);
  58. } // namespace function
  59. } // namespace ultra_infer