ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Utils.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 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 __KBENCHMARK_UTILS_H__
18#define __KBENCHMARK_UTILS_H__
19
20#include <sstream>
21#include <string>
22#include <vector>
23#include <cassert>
24
25namespace kbenchmark
26{
27
28void check_valid_key(const std::string &key, OperationInfo &info)
29{
30 OperationInfo::const_iterator it;
31 it = info.find(key);
32 assert(it != info.end());
33}
34
35std::vector<int> dims(const std::string &src)
36{
37 std::vector<int> dim;
38
39 std::stringstream ss(src);
40 int i;
41 while (ss >> i)
42 {
43 dim.push_back(i);
44 if (ss.peek() == ',')
45 ss.ignore();
46 }
47 return dim;
48}
49
50std::vector<int> get_key_dims(const std::string &key, OperationInfo &info)
51{
53 return dims(info[key]);
54}
55
56int get_key_int(const std::string &key, OperationInfo &info)
57{
59 return std::stoi(info[key]);
60}
61
62std::string get_key_string(const std::string &key, OperationInfo &info)
63{
65 return info[key];
66}
67
68} // namespace kbenchmark
69
70#endif // __KBENCHMARK_UTILS_H__
volatile const char info[]
std::vector< int > dims(const std::string &src)
Definition Utils.h:35
int get_key_int(const std::string &key, OperationInfo &info)
Definition Utils.h:56
std::map< std::string, std::string > OperationInfo
Definition ConfigFile.h:62
std::string get_key_string(const std::string &key, OperationInfo &info)
Definition Utils.h:62
std::vector< int > get_key_dims(const std::string &key, OperationInfo &info)
Definition Utils.h:50
void check_valid_key(const std::string &key, OperationInfo &info)
Definition Utils.h:28