Elffuss BraidHub

kikocis/ncnn public

master · 2.2 KiBRawPermalink
1// Tencent is pleased to support the open source community by making ncnn available.
2//
3// Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4//
5// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6// in compliance with the License. You may obtain a copy of the License at
7//
8// https://opensource.org/licenses/BSD-3-Clause
9//
10// Unless required by applicable law or agreed to in writing, software distributed
11// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13// specific language governing permissions and limitations under the License.
14
15#ifndef NCNN_MODELBIN_H
16#define NCNN_MODELBIN_H
17
18#include "mat.h"
19
20namespace ncnn {
21
22class DataReader;
23class NCNN_EXPORT ModelBin
24{
25public:
26 ModelBin();
27 virtual ~ModelBin();
28 // element type
29 // 0 = auto
30 // 1 = float32
31 // 2 = float16
32 // 3 = int8
33 // load vec
34 virtual Mat load(int w, int type) const;
35 // load image
36 virtual Mat load(int w, int h, int type) const;
37 // load dim
38 virtual Mat load(int w, int h, int c, int type) const;
39 // load cube
40 virtual Mat load(int w, int h, int d, int c, int type) const;
41};
42
43class ModelBinFromDataReaderPrivate;
44class NCNN_EXPORT ModelBinFromDataReader : public ModelBin
45{
46public:
47 explicit ModelBinFromDataReader(const DataReader& dr);
48 virtual ~ModelBinFromDataReader();
49
50 virtual Mat load(int w, int type) const;
51
52private:
53 ModelBinFromDataReader(const ModelBinFromDataReader&);
54 ModelBinFromDataReader& operator=(const ModelBinFromDataReader&);
55
56private:
57 ModelBinFromDataReaderPrivate* const d;
58};
59
60class ModelBinFromMatArrayPrivate;
61class NCNN_EXPORT ModelBinFromMatArray : public ModelBin
62{
63public:
64 // construct from weight blob array
65 explicit ModelBinFromMatArray(const Mat* weights);
66 virtual ~ModelBinFromMatArray();
67
68 virtual Mat load(int w, int type) const;
69
70private:
71 ModelBinFromMatArray(const ModelBinFromMatArray&);
72 ModelBinFromMatArray& operator=(const ModelBinFromMatArray&);
73
74private:
75 ModelBinFromMatArrayPrivate* const d;
76};
77
78} // namespace ncnn
79
80#endif // NCNN_MODELBIN_H