NCNN 源码剖析(二) Blob

blob 类头文件中声明如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Blob
{
public:
// empty
Blob();

public:
#if NCNN_STRING
// blob name
std::string name;
#endif // NCNN_STRING
// layer index which produce this blob as output
int producer;
// layer index which need this blob as input
std::vector<int> consumers;
}

其默认构造函数仅仅是将 producer 设置为 -1.

blob 的作用是描述网络的结构。网络之间的输入输出关系。producer 声明了以这个 blob 为输出的 layer index. consumers 声明了需要这个 blob 作为输入的 layer index.