paramdict.h 1.7 KB

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