ONE - On-device Neural Engine
Loading...
Searching...
No Matches
PALConv2d.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 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 LUCI_INTERPRETER_PAL_CONV2D_H
18#define LUCI_INTERPRETER_PAL_CONV2D_H
19
20#include <tensorflow/lite/kernels/internal/reference/conv.h>
21#include <tensorflow/lite/kernels/internal/reference/integer_ops/conv.h>
22
24{
25static inline void Conv(const tflite::ConvParams &params, const tflite::RuntimeShape &input_shape,
26 const float *input_data, const tflite::RuntimeShape &filter_shape,
27 const float *filter_data, const tflite::RuntimeShape &bias_shape,
28 const float *bias_data, const tflite::RuntimeShape &output_shape,
29 float *output_data, const tflite::RuntimeShape &scratchpad_shape,
30 float *scratchpad_data)
31{
32 (void)scratchpad_shape;
33 (void)scratchpad_data;
34 tflite::reference_ops::Conv(params, input_shape, input_data, filter_shape, filter_data,
35 bias_shape, bias_data, output_shape, output_data,
36 tflite::RuntimeShape(), nullptr);
37}
38
39static inline void Conv(const tflite::ConvParams &params, const tflite::RuntimeShape &input_shape,
40 const uint8 *input_data, const tflite::RuntimeShape &filter_shape,
41 const uint8 *filter_data, const tflite::RuntimeShape &bias_shape,
42 const int32 *bias_data, const tflite::RuntimeShape &output_shape,
43 uint8 *output_data, const tflite::RuntimeShape &scratchpad_shape,
44 uint8 *scratchpad_data)
45{
46 (void)scratchpad_shape;
47 (void)scratchpad_data;
48 tflite::reference_ops::Conv(params, input_shape, input_data, filter_shape, filter_data,
49 bias_shape, bias_data, output_shape, output_data, scratchpad_shape,
50 scratchpad_data, nullptr);
51}
52
53static inline void ConvPerChannel(const tflite::ConvParams &params, const int32_t *mult,
54 const int32_t *shifts, const tflite::RuntimeShape &input_shape,
55 const int8 *input_data, const tflite::RuntimeShape &filter_shape,
56 const int8 *filter_data, const tflite::RuntimeShape &bias_shape,
57 const int32 *bias_data, const tflite::RuntimeShape &output_shape,
58 int8 *output_data, const tflite::RuntimeShape &scratchpad_shape,
59 int8 *scratchpad_data)
60{
61 (void)scratchpad_shape;
62 (void)scratchpad_data;
63 tflite::reference_integer_ops::ConvPerChannel(params, mult, shifts, input_shape, input_data,
64 filter_shape, filter_data, bias_shape, bias_data,
65 output_shape, output_data);
66}
67
68static inline void SetupScratchpadTensor(luci_interpreter::Tensor *scratchpad,
69 const luci_interpreter::DataType &input_data_type,
70 const tflite::ConvParams &params,
71 const tflite::RuntimeShape &input_shape,
72 const tflite::RuntimeShape &filter_shape,
73 const tflite::RuntimeShape &output_shape)
74{
75 (void)input_data_type;
76 (void)params;
77 (void)input_shape;
78 (void)filter_shape;
79 (void)output_shape;
80 scratchpad->set_allocatable(false);
81}
82
83} // namespace luci_interpreter_pal
84
85#endif // LUCI_INTERPRETER_PAL_CONV2D_H
std::uint8_t uint8
Definition Macro.h:52
void set_allocatable(bool value)
Definition Tensor.h:168
const luci_interpreter::RuntimeShape output_shape
DataType
"scalar" value type
Definition DataType.h:32
void Conv(const ConvParams &params, const Shape &input_shape, const uint8_t *input_data, const Shape &filter_shape, const uint8_t *filter_data, const Shape &bias_shape, const int32_t *bias_data, const Shape &output_shape, uint8_t *output_data, const Shape &im2col_shape, uint8_t *im2col_data)
Definition Conv.h:83
int32_t int32
Definition topk_v2.h:27