---
title: MemoryType
description: "内存类型枚举，头文件位于CANN软件安装后文件存储路径下的include/ge/ge_api_types.h。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/atlasgeapi_07_0147.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/atlasgeapi_07_0147.html
indexId: 72188b25245b3b774bc05a04773a47814bd4b66b20ed2292a41cefc1c79c2b3f72
---
# MemoryType

内存类型枚举，头文件位于CANN软件安装后文件存储路径下的include/ge/ge_api_types.h。

```
enum class MemoryType : std::int64_t {
  /*
   * call aclrtMalloc with aclrtMemMallocPolicy::ACL_MEM_MALLOC_HUGE_FIRST,
   * ACL_MEM_MALLOC_HUGE_ONLY, ACL_MEM_MALLOC_NORMAL_ONLY
   */
  MEMORY_TYPE_DEFAULT,
  /*
   * call aclrtMalloc with aclrtMemMallocPolicy::ACL_MEM_MALLOC_HUGE_FIRST_P2P,
   * ACL_MEM_MALLOC_HUGE_ONLY_P2P, ACL_MEM_MALLOC_NORMAL_ONLY_P2P
   */
  MEMORY_TYPE_P2P
};
```

各枚举项说明如下：

- MEMORY_TYPE_DEFAULT：默认Device内存类型，可以通过调用“  aclrtMalloc(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_0095.html)
”接口申请得到，申请内存时传入“  aclrtMemMallocPolicy(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_1349.html)
”中的3种枚举值之一，ACL_MEM_MALLOC_HUGE_FIRST、ACL_MEM_MALLOC_HUGE_ONLY、 ACL_MEM_MALLOC_NORMAL_ONLY
- MEMORY_TYPE_P2P：仅Device之间内存复制场景下的内存类型，可以通过调用  aclrtMalloc(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_0095.html)
接口申请得到，申请内存时传入  aclrtMemMallocPolicy(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_1349.html)
中的3种枚举值之一，ACL_MEM_MALLOC_HUGE_FIRST_P2P、ACL_MEM_MALLOC_HUGE_ONLY_P2P、ACL_MEM_MALLOC_NORMAL_ONLY_P2P
