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.

ssd_prior_box_kernel.h 4.8 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * Copyright 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_GRAPH_PASSES_FOLDING_KERNEL_SSD_PRIOR_BOX_KERNEL_H_
  17. #define GE_GRAPH_PASSES_FOLDING_KERNEL_SSD_PRIOR_BOX_KERNEL_H_
  18. #include <memory>
  19. #include <vector>
  20. #include "inc/kernel.h"
  21. namespace ge {
  22. class SsdPriorboxKernel : public Kernel {
  23. public:
  24. /**
  25. * Entry of the SsdPriorboxKernel optimizer
  26. * @param [in] node: Input Node
  27. * @return SUCCESS: node output compute success
  28. * @return OTHERS: Execution failed
  29. * @author
  30. */
  31. Status Compute(const NodePtr &node, std::vector<GeTensorPtr> &v_output) override;
  32. private:
  33. /**
  34. * Get specific op_desc attr value
  35. * @param [in] op_desc: Input op_desc
  36. * @param [in/out] img_width: img_width attr_value
  37. * @param [in/out] img_height: img_height attr_value
  38. * @param [in/out] step_h: step_h attr_value
  39. * @param [in/out] step_w: step_w attr_value
  40. * @param [in/out] layer_width: layer_width attr_value
  41. * @param [in/out] layer_height: layer_height attr_value
  42. * @return SUCCESS: node get attr value success
  43. * @return OTHERS: Execution failed
  44. * @author
  45. */
  46. Status GetPriorSizeParam(const OpDescPtr &op_desc, int &img_width, int &img_height, float &step_w, float &step_h,
  47. int &layer_width, int &layer_height);
  48. /**
  49. * Get specific op_desc size attr value,min_size_num etc.
  50. * @param [in] op_desc: Input op_desc
  51. * @param [in/out] offset: offset attr_value
  52. * @param [in/out] clip: clip attr_value
  53. * @return SUCCESS: get attr success
  54. * @return OTHERS: Execution failed
  55. * @author
  56. */
  57. Status GetPriorOtherParam(const OpDescPtr &op_desc, float &offset, bool &clip);
  58. /**
  59. * Get specific op_desc list attr value,min_size_list etc.
  60. * @param [in] op_desc: Input op_desc
  61. * @param [in/out] min_size_list: min_size_list attr_value
  62. * @param [in/out] max_size_list: max_size_list attr_value
  63. * @param [in/out] aspect_ratio_list: aspect_ratio_list attr_value
  64. * @param [in/out] variance_list: variance_list attr_value
  65. * @param [in/out] clip: clip attr_value
  66. * @return SUCCESS: get list attr success
  67. * @return OTHERS: Execution failed
  68. * @author
  69. */
  70. Status GetPriorListParam(const OpDescPtr &op_desc, vector<float> &min_size_list, vector<float> &max_size_list,
  71. vector<float> &aspect_ratio_list, vector<float> &variance_list);
  72. /**
  73. * set variance param to output_data.
  74. * @param [in] variance: variance list
  75. * @param [in] dim: output_data second channel offset
  76. * @param [in] layer_height: layer_height
  77. * @param [in] num_priors: num_priors
  78. * @param [in/out] output_data: output_data
  79. * @return SUCCESS: set variance success
  80. * @return OTHERS: Execution failed
  81. * @author
  82. */
  83. Status SetVariance(const vector<float> &variance, const int dim, const int32_t layer_height,
  84. const int32_t layer_width, const int num_priors, float *output_data);
  85. /**
  86. * get num priors and dim size.
  87. * @param [in] aspect_ratios_size: aspect_ratio_list size
  88. * @param [in] min_sizes_size: min_size_list size
  89. * @param [in] max_sizes_size: max_size_list size
  90. * @param [in] layer_width: layer_width
  91. * @param [in] layer_height: layer_height
  92. * @param [in/out] num_priors: num_priors
  93. * @param [in/out] dim_size: dim_size
  94. * @return SUCCESS: set variance success
  95. * @return OTHERS: Execution failed
  96. * @author
  97. */
  98. Status GetNumPriorAndDimSize(uint aspect_ratios_size, uint min_sizes_size, uint max_sizes_size, int layer_width,
  99. int layer_height, int &num_priors, int &dim_size) const;
  100. void DataCalulate(float x, float y, float box_x, float box_y, int img_x, int img_y, vector<float> &result);
  101. std::unique_ptr<float[]> BoundaryCalulate(int dim_size, int layer_width, int layer_height, float step_width,
  102. float step_height, int img_width, int img_height, float offset,
  103. vector<float> min_sizes, vector<float> max_sizes,
  104. vector<float> aspect_ratios);
  105. };
  106. } // namespace ge
  107. #endif // GE_GRAPH_PASSES_FOLDING_KERNEL_SSD_PRIOR_BOX_KERNEL_H_

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