ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Convolution.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_OPERATIONS_CONVOLUTION_H__
18#define __KBENCHMARK_OPERATIONS_CONVOLUTION_H__
19
20#include "Operation.h"
21#include "Utils.h"
22
23namespace kbenchmark
24{
25namespace operation
26{
27
28class Convolution final : public Operation
29{
30public:
31 Convolution() = default;
32
33 nonius::parameters params(int layer_num, OperationInfo &info) override
34 {
35 nonius::parameters params;
36
37 params.insert({"LAYER", nonius::param{layer_num}});
38
39 params.insert({"BATCH", nonius::param{1}});
40
41 auto _input = get_key_dims({"input"}, info);
42 params.insert({"IFM_C", nonius::param{_input[3]}});
43 params.insert({"IFM_H", nonius::param{_input[1]}});
44 params.insert({"IFM_W", nonius::param{_input[2]}});
45
46 auto _output0 = get_key_dims({"output0"}, info);
47 params.insert({"OFM_C", nonius::param{_output0[3]}});
48 params.insert({"OFM_H", nonius::param{_output0[1]}});
49 params.insert({"OFM_W", nonius::param{_output0[2]}});
50
51 auto _weights = get_key_dims({"weights"}, info);
52 params.insert({"KER_H", nonius::param{_weights[1]}});
53 params.insert({"KER_W", nonius::param{_weights[2]}});
54
55 auto _stride_h = get_key_int({"stride_h"}, info);
56 auto _stride_w = get_key_int({"stride_w"}, info);
57 params.insert({"STRIDE_H", nonius::param{_stride_h}});
58 params.insert({"STRIDE_W", nonius::param{_stride_w}});
59
60 auto _pad = get_key_string({"padding"}, info);
61 params.insert({"PADDING", nonius::param{_pad}});
62
63 auto _act = get_key_string({"fused_act"}, info);
64 params.insert({"FUSED_ACT", nonius::param{_act}});
65
66 return params;
67 }
68};
69
70} // namespace operation
71} // namespace kbenchmark
72
73#endif // __KBENCHMARK_OPERATIONS_CONVOLUTION_H__
nonius::parameters params(int layer_num, OperationInfo &info) override
Definition Convolution.h:33
volatile const char info[]
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