函数功能
查询图编译结果的概要信息。包括Feature内存大小、Const内存大小、Stream、Event数目及内存是否可刷新等信息。您可以根据该信息,自行申请内存,再通过如下接口设置或更新Feature内存、Const内存基址:
函数原型
| CompiledGraphSummaryPtr GetCompiledGraphSummary(uint32_t graph_id)
|
参数说明
参数名
|
输入/输出
|
描述
|
graph_id
|
输入
|
子图对应的id。
|
返回值
参数名
|
类型
|
描述
|
-
|
CompiledGraphSummaryPtr
|
图编译结果的概要信息CompiledGraphSummary的share_ptr。
CompiledGraphSummary具体结构如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 | class GE_FUNC_VISIBILITY CompiledGraphSummary {
public:
class Builder;
class SummaryData;
~CompiledGraphSummary();
CompiledGraphSummary &operator=(const CompiledGraphSummary &) & = delete;
CompiledGraphSummary(const CompiledGraphSummary &) = delete;
// 返回graph是否是静态编译的,只有在静态编译的情况下,才可以使用后续的获取Summary信息的接口(GetFixedFeatureMemorySize/GetAllFeatureMemoryTypeSize接口除外)
bool IsStatic() const;
// 获取编译后的Const内存大小
Status GetConstMemorySize(size_t &size) const;
// 获取编译后的全量Feature内存大小(包含Fixed固定内存)
Status GetFeatureMemorySize(size_t &size) const;
// 获取Feature基址是否可刷新
Status GetFeatureMemoryBaseRefreshable (bool &v) const;
// 获取编译后逻辑地址相同的graph输入索引和输出索引对
Status GetIOIndexesWithSameAddr(std::vector<std::pair<uint32_t, uint32_t>> &io_indexes) const;
// 获取Stream数目
Status GetStreamNum(size_t &num) const;
// 获取Event数目
Status GetEventNum(size_t &num) const;
// 该接口只适用于静态shape图,获取图编译的输出shape,输出shape可用于计算outputs所占内存大小;对于动态多档位图,获取当前最大档位的输出shape
Status GetOutputShapes(std::vector<ge::Shape> &shapes) const;
// 获取图编译的输出Dtypes
Status GetOutputDtypes(std::vector<ge::DataType> &dtypes) const;
//获取输入(refdata)在各个device上的切分信息
Status GetInputShardMethod(std::map<std::string, std::map<int32_t, std::vector<std::pair<int64_t, int64_t>>>>&device_id_to_tensor_deployment) const;
//用于获取Fixed内存总大小(适用于静态shape图和动态shape图)
Status GetFixedFeatureMemorySize(size_t &size) const;
//用于获取除了Fixed之外可刷新内存的总大小
Status GetRefreshableFeatureMemorySize(size_t &sizes) const;
//用于获取所有内存类型的Feature内存列表,当前仅包含Fixed的内存(适用于静态shape图和动态shape图)
std::vector<FeatureMemoryPtr> GetAllFeatureMemoryTypeSize() const;
private:
CompiledGraphSummary() = default;
std::shared_ptr<SummaryData> data_{nullptr};
};
|
Status返回值有如下两个取值:
- SUCCESS:接口调用成功。
- FAILED:接口调用失败。
GetAllFeatureMemoryTypeSize返回值为:图编译结果中Feature memory信息FeatureMemory的shared_ptr
FeatureMemory具体结构如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | class GE_FUNC_VISIBILITY FeatureMemory {
public:
class Builder;
class FeatureMemoryData;
~FeatureMemory();
FeatureMemory &operator=(const FeatureMemory &) & = delete;
FeatureMemory(const FeatureMemory &) = delete;
//内存类型
MemoryType GetType() const;
//内存大小
size_t GetSize() const;
//是不是Fixed内存
bool IsFixed() const;
private:
FeatureMemory() = default;
std::shared_ptr<FeatureMemoryData> data_{nullptr};
};
|
|