Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / runtime / onert / core / src / dumper / h5 / MinMaxDumper.h
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __ONERT_DUMPER_H5_MINMAX_DUMPER_H__
18 #define __ONERT_DUMPER_H5_MINMAX_DUMPER_H__
19
20 #include "exec/MinMaxMap.h"
21 #include "Dumper.h"
22
23 #include <H5Cpp.h>
24 #include <string>
25
26 namespace onert
27 {
28 namespace dumper
29 {
30 namespace h5
31 {
32
33 // The hierachy of single model minmax h5 file
34 //
35 // GROUP /
36 //   GROUP value
37 //     └── GROUP run_idx
38 //           └── GROUP model_idx
39 //                 └── GROUP subg_idx
40 //                       └── DATASET op_idx
41 //                              DATATYPE Float32
42 //                              DATASPACE (2)
43 //                              DATA { min, max }
44 //   GROUP name   (optional, for debug)
45 //     └── GROUP model_idx
46 //           └── GROUP subg_idx
47 //                 └── ATTRIBUTE op_idx
48 //                        DATATYPE String
49 //                        DATA { "model/your/op/name"}
50 //
51 class MinMaxDumper : private Dumper
52 {
53 public:
54   MinMaxDumper(const std::string &filepath);
55   /**
56    * @brief Dump minmax map
57    *
58    * @param[in] map  single model minmax map
59    */
60   void dump(const exec::SMMinMaxMap &map) const;
61
62 private:
63   H5::Group _val_grp;
64 };
65
66 } // namespace h5
67 } // namespace dumper
68 } // namespace onert
69
70 #endif // __ONERT_DUMPER_H5_MINMAX_DUMPER_H__