You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

fp16_math.h 4.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef GE_COMMON_MATH_FP16_MATH_H_
  17. #define GE_COMMON_MATH_FP16_MATH_H_
  18. #include "common/fp16_t.h"
  19. namespace ge {
  20. /// @ingroup fp16_t mathematics method
  21. /// @param [in] fp fp16_t object to be calculate
  22. /// @brief Calculates fp16_t square root function of input fp
  23. /// @return Returns fp16_t square root of fp
  24. fp16_t sqrt(fp16_t fp);
  25. /// @ingroup fp16_t mathematics method
  26. /// @param [in] fp fp16_t object to be calculate
  27. /// @brief Calculates fp16_t reciprocal square root function of input fp
  28. /// @return Returns fp16_t reciprocal square root of fp
  29. fp16_t rsqrt(fp16_t fp);
  30. /// @ingroup fp16_t mathematics method
  31. /// @param [in] fp fp16_t object to be calculate
  32. /// @brief Calculates fp16_t reciprocal function of input fp
  33. /// @return Returns fp16_t reciprocal of fp
  34. fp16_t rcp(fp16_t fp);
  35. /// @ingroup fp16_t mathematics method
  36. /// @param [in] fp fp16_t object to be calculate
  37. /// @brief Calculates fp16_t natural exponential function of input fp
  38. /// @return Returns fp16_t natural exponential function of fp
  39. fp16_t exp(fp16_t fp);
  40. /// @ingroup fp16_t mathematics method
  41. /// @param [in] fp fp16_t object to be calculate
  42. /// @brief Calculates fp16_t binary exponential function of input fp
  43. /// @return Returns fp16_t binary exponential function of fp
  44. fp16_t pow2(fp16_t fp);
  45. /// @ingroup fp16_t mathematics method
  46. /// @param [in] fp_v fp16_t object to be calculate
  47. /// @brief Calculates fp16_t decimal exponential function of input fp
  48. /// @return Returns fp16_t decimal exponential function of fp
  49. fp16_t pow10(fp16_t fp);
  50. /// @ingroup fp16_t mathematics method
  51. /// @param [in] fp_v fp16_t object to be calculate
  52. /// @brief Calculate fp16_t natural logarithm of fp16_t
  53. /// @return Returns fp16_t natural logarithm of fp
  54. fp16_t ln(fp16_t fp);
  55. /// @ingroup fp16_t mathematics method
  56. /// @param [in] fp fp16_t object to be calculate
  57. /// @brief Calculate fp16_t binary logarithm of fp16_t
  58. /// @return Returns fp16_t binary logarithm of fp
  59. fp16_t log2(fp16_t fp);
  60. /// @ingroup fp16_t mathematics method
  61. /// @param [in] fp fp16_t object to be calculate
  62. /// @brief Calculate fp16_t decimal logarithm of fp16_t
  63. /// @return Returns fp16_t decimal logarithm of fp
  64. fp16_t log10(fp16_t fp);
  65. /// @ingroup fp16_t mathematics method
  66. /// @param [in] fp fp16_t object to be calculate
  67. /// @brief Calculate fp16_t cosine of fp16_t
  68. /// @return Returns fp16_t cosine of fp
  69. fp16_t cos(fp16_t fp);
  70. /// @ingroup fp16_t mathematics method
  71. /// @param [in] fp fp16_t object to be calculate
  72. /// @brief Calculate fp16_t sine of fp16_t
  73. /// @return Returns fp16_t sine of fp
  74. fp16_t sin(fp16_t fp);
  75. /// @ingroup fp16_t mathematics method
  76. /// @param [in] fp fp16_t object to be calculate
  77. /// @brief Calculate the absolute value(the sign bit is 0) of the give value
  78. /// @return Returns fp16_t absolute value(the sign bit is 0) of of fp
  79. fp16_t abs(fp16_t fp);
  80. /// @ingroup fp16_t mathematics method
  81. /// @param [in] fp1 fp16_t object to be compare
  82. /// @param [in] fp2 fp16_t object to be compare
  83. /// @brief Calculate the maximum fp16_t of fp1 and fp2
  84. /// @return Returns maximum fp16_t of fp1 and fp2
  85. fp16_t max(fp16_t fp1, fp16_t fp2);
  86. /// @ingroup fp16_t mathematics method
  87. /// @param [in] fp1 fp16_t object to be compare
  88. /// @param [in] fp2 fp16_t object to be compare
  89. /// @brief Calculate the minimum fp16_t of fp1 and fp2
  90. /// @return Returns minimum fp16_t of fp1 and fp2
  91. fp16_t min(fp16_t fp1, fp16_t fp2);
  92. } // namespace ge
  93. #endif // GE_COMMON_MATH_FP16_MATH_H_

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示