ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Reader.h
Go to the documentation of this file.
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 __MINMAX_EMBEDDER_H5_READER_H__
18#define __MINMAX_EMBEDDER_H5_READER_H__
19
20#include <H5Cpp.h>
21#include <string>
22#include <utility>
23#include <vector>
24
25namespace minmax_embedder
26{
27namespace h5
28{
29// The hierachy of single model minmax h5 file
30//
31// GROUP /
32// GROUP value
33// └── GROUP run_{idx}
34// └── GROUP model_{idx}
35// └── GROUP subg_{idx}
36// ├── DATASET op_{idx}
37// │ DATATYPE Float32
38// │ DATASPACE (2)
39// │ DATA { min, max }
40// └── DATASET input_{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 { "op/name"}
50// └── ATTRIBUTE input_{idx}
51// DATATYPE String
52// DATA { "input/name"}
54{
55 std::vector<float> min_vector;
56 std::vector<float> max_vector;
57};
58
59class Reader
60{
61public:
62 Reader(const std::string &filepath);
68 MinMaxVectors read(int model_idx, int subg_idx, int op_idx) const;
74 MinMaxVectors read_input(int model_idx, int subg_idx, int input_idx) const;
75
76private:
77 H5::H5File _file;
78 H5::Group _val_grp;
79};
80
81} // namespace h5
82} // namespace minmax_embedder
83
84#endif // __MINMAX_EMBEDDER_H5_READER_H__
MinMaxVectors read_input(int model_idx, int subg_idx, int input_idx) const
Returns minmax recording for input {model_idx, subg_idx, input_idx}.
Definition Reader.cpp:65
MinMaxVectors read(int model_idx, int subg_idx, int op_idx) const
Returns minmax recording for op {model_idx, subg_idx, op_idx}.
Definition Reader.cpp:39
h5
Definition infer.py:88
std::vector< float > max_vector
Definition Reader.h:56
std::vector< float > min_vector
Definition Reader.h:55