ONE - On-device Neural Engine
Loading...
Searching...
No Matches
DepthwiseConv2D.h
Go to the documentation of this file.
1/* Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef __LUCI_COMPUTE_DEPTHWISE_CONV2D_H__
17#define __LUCI_COMPUTE_DEPTHWISE_CONV2D_H__
18
19#include "Types.h"
20
21#include <loco/IR/TensorShape.h>
22
23namespace luci
24{
25namespace compute
26{
27
28// TODO extract some common for multiple Ops
30{
31public:
32 DepthwiseConv2D() = default;
33
34public:
35 DepthwiseParams &params(void) { return _params; }
36
37 void input(const loco::TensorShape &shape, const float *data)
38 {
39 _input_shape = shape;
40 _input_data = data;
41 }
42
43 void filter(const loco::TensorShape &shape, const float *data)
44 {
45 _filter_shape = shape;
46 _filter_data = data;
47 }
48
49 void bias(const loco::TensorShape &shape, const float *data)
50 {
51 _bias_shape = shape;
52 _bias_data = data;
53 }
54
55 void fused_act_func(FusedActFunc func) { _fused_act_func = func; };
56
57 void output(float *data) { _output_data = data; }
58
59public:
60 bool prepare(void);
61 const loco::TensorShape &output_shape(void) const { return _output_shape; }
62 void compute(void);
63
64private:
65 // param to pass to compute kernel
66 DepthwiseParams _params = {};
67 // shape and data for inputs
68 loco::TensorShape _input_shape;
69 loco::TensorShape _filter_shape;
70 loco::TensorShape _bias_shape;
71 const float *_input_data = nullptr;
72 const float *_filter_data = nullptr;
73 const float *_bias_data = nullptr;
74 FusedActFunc _fused_act_func = FusedActFunc::UNDEFINED;
75
76 // compute results
77 loco::TensorShape _output_shape;
78 float *_output_data = nullptr;
79};
80
81} // namespace compute
82} // namespace luci
83
84#endif // __LUCI_COMPUTE_DEPTHWISE_CONV2D_H__
void filter(const loco::TensorShape &shape, const float *data)
const loco::TensorShape & output_shape(void) const
DepthwiseParams & params(void)
void bias(const loco::TensorShape &shape, const float *data)
void input(const loco::TensorShape &shape, const float *data)
void fused_act_func(FusedActFunc func)
const T * data(const std::vector< T, Alloc > &v)