2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "kernels/LocalResponseNormalization.h"
19 #include "kernels/Utils.h"
21 #include "PALLocalResponseNormalization.h"
23 namespace luci_interpreter
29 LocalResponseNormalization::LocalResponseNormalization(
30 const Tensor *input, Tensor *output, const LocalResponseNormalizationParams ¶ms)
31 : KernelWithParams<LocalResponseNormalizationParams>({input}, {output}, params)
35 void LocalResponseNormalization::configure()
37 LUCI_INTERPRETER_CHECK(input()->shape().num_dims() == 4);
38 LUCI_INTERPRETER_CHECK(output()->element_type() == DataType::FLOAT32);
39 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
40 // TODO: enable it only if kernel with dynamic shapes
41 output()->resize(input()->shape());
44 void LocalResponseNormalization::execute() const
46 switch (output()->element_type())
48 case DataType::FLOAT32:
49 tflite::LocalResponseNormalizationParams op_params;
50 op_params.range = params().radius;
51 op_params.bias = params().bias;
52 op_params.alpha = params().alpha;
53 op_params.beta = params().beta;
54 luci_interpreter_pal::LocalResponseNormalization(
55 op_params, getTensorShape(input()), getTensorData<float>(input()), getTensorShape(output()),
56 getTensorData<float>(output()));
59 assert(false && "Unsupported type.");
63 } // namespace kernels
64 } // namespace luci_interpreter