Elffuss BraidHub

kikocis/ncnn public

master · 1.7 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_PARAMDICT_H
16#define NCNN_PARAMDICT_H
17
18#include "mat.h"
19
20// at most 32 parameters
21#define NCNN_MAX_PARAM_COUNT 32
22
23namespace ncnn {
24
25class DataReader;
26class Net;
27class ParamDictPrivate;
28class NCNN_EXPORT ParamDict
29{
30public:
31 // empty
32 ParamDict();
33
34 virtual ~ParamDict();
35
36 // copy
37 ParamDict(const ParamDict&);
38
39 // assign
40 ParamDict& operator=(const ParamDict&);
41
42 // get type
43 int type(int id) const;
44
45 // get int
46 int get(int id, int def) const;
47 // get float
48 float get(int id, float def) const;
49 // get array
50 Mat get(int id, const Mat& def) const;
51
52 // set int
53 void set(int id, int i);
54 // set float
55 void set(int id, float f);
56 // set array
57 void set(int id, const Mat& v);
58
59protected:
60 friend class Net;
61
62 void clear();
63
64 int load_param(const DataReader& dr);
65 int load_param_bin(const DataReader& dr);
66
67private:
68 ParamDictPrivate* const d;
69};
70
71} // namespace ncnn
72
73#endif // NCNN_PARAMDICT_H