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.

hcom.h 3.3 kB

5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 __HCOM_H__
  17. #define __HCOM_H__
  18. #include <runtime/rt.h>
  19. #include <hccl/base.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. extern hcclResult_t hcom_init(const char *rank_table, const char *identify);
  24. extern hcclResult_t hcom_destroy(void);
  25. extern hcclResult_t hcom_bind_model(rtModel_t model, rtStream_t stream);
  26. extern hcclResult_t hcom_unbind_model(rtModel_t model);
  27. extern hcclResult_t hcom_all_gather(const char *tag, void *inputPtr, void *outputPtr, u64 inputCount,
  28. hcclDataType_t dataType, const char *group, rtStream_t stream);
  29. extern hcclResult_t hcom_all_reduce(const char *tag, void *inputPtr, void *outputPtr, u64 count,
  30. hcclDataType_t dataType, hcclRedOp_t op, const char *group, rtStream_t stream);
  31. extern hcclResult_t hcom_broadcast(const char *tag, void *ptr, u64 count, hcclDataType_t dataType, u32 root,
  32. const char *group, rtStream_t stream);
  33. extern hcclResult_t hcom_reduce_scatter(const char *tag, void *inputPtr, void *outputPtr, u64 count,
  34. hcclDataType_t dataType, hcclRedOp_t op, const char *group, rtStream_t stream);
  35. hcclResult_t hcom_get_rank_size(const char *group, u32 *rankSize);
  36. hcclResult_t hcom_get_local_rank_size(const char *group, u32 *localRankSize);
  37. hcclResult_t hcom_get_rank_id(const char *group, u32 *rankId);
  38. hcclResult_t hcom_get_local_rank_id(const char *group, u32 *localRankId);
  39. hcclResult_t hcom_get_world_rank_from_group_rank(const char *group, u32 groupRank, u32 *worldRank);
  40. hcclResult_t hcom_get_group_rank_from_world_rank(u32 worldRank, const char *group, u32 *groupRank);
  41. hcclResult_t hcom_create_group(const char *group, u32 rankNum, u32 *rankIds);
  42. hcclResult_t hcom_destroy_group(const char *group);
  43. hcclResult_t hcom_send(const char *tag, void *inputPtr, u64 count, hcclDataType_t dataType, u32 destRank, u32 srTag,
  44. const char *group, rtStream_t stream);
  45. hcclResult_t hcom_receive(const char *tag, void *outputPtr, u64 count, hcclDataType_t dataType, u32 srcRank, u32 srTag,
  46. const char *group, rtStream_t stream);
  47. hcclResult_t hcom_get_split_strategy(const char *group, const struct model_feature *feature, u32 maxSegmentNum,
  48. u32 *segmentNum, u32 *segmentIdx);
  49. extern hcclResult_t hcom_set_split_strategy_by_index(const char *group, u32 segmentNum, const u32 *IdxList);
  50. extern hcclResult_t hcom_set_split_strategy_by_size(const char *group, u32 segmentNum, const float *sizeList);
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif // __HCOM_H__

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