ONE - On-device Neural Engine
Loading...
Searching...
No Matches
PRelu.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 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#include "Builders.h"
18#include "kernels/Utils.h"
19#include "TISOKernel.h"
20
21#include "PALPreluCommon.h"
22
23namespace luci_interpreter
24{
25
26void configure_kernel_CirclePRelu(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
27{
28 kernels::TISOKernel kernel(cur_op, runtime_graph);
29
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
31 Tensor::element_type(kernel.output()));
32 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
33 Tensor::element_type(kernel.input2()));
34
35 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) == Tensor::num_dims(kernel.output()));
36 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input1()) ==
37 Tensor::num_elements(kernel.output()));
38}
39
40void execute_kernel_CirclePRelu(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
41{
42 kernels::TISOKernel kernel(cur_op, runtime_graph);
43 kernels::TISOData kernel_data = kernel.readData();
44
45 switch (Tensor::element_type(kernel.input1()))
46 {
47#ifndef DIS_FLOAT
48 case DataType::FLOAT32:
49 {
50 const float *input_data_float = kernels::getTensorData<float>(kernel_data.input1_data);
51 const float *alpha_data_float = kernels::getTensorData<float>(kernel_data.input2_data);
52 float *output_data_float = kernels::getTensorData<float>(kernel_data.output_data);
53 assert(output_data_float);
54 assert(input_data_float);
55 assert(alpha_data_float);
56
58 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph), input_data_float,
59 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph), alpha_data_float,
60 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph), output_data_float);
61 break;
62 }
63#endif // DIS_FLOAT
64 default:
65 assert(false && "Unsupported type");
66 }
67}
68
69} // namespace luci_interpreter
const circle::Tensor * output() const
Definition TISOKernel.h:62
const circle::Tensor * input2() const
Definition TISOKernel.h:61
const circle::Tensor * input1() const
Definition TISOKernel.h:60
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
luci_interpreter::RuntimeShape getTensorRuntimeShape(const circle::Tensor *circle_tensor, BaseRuntimeGraph *runtime_graph)
Definition Utils.cpp:29
void BroadcastPrelu4DSlowFloat(const luci_interpreter::RuntimeShape &unextended_input1_shape, const float *input1_data, const luci_interpreter::RuntimeShape &unextended_input2_shape, const float *input2_data, const luci_interpreter::RuntimeShape &unextended_output_shape, float *output_data)
void configure_kernel_CirclePRelu(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
Definition PRelu.cpp:26
void execute_kernel_CirclePRelu(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
Definition PRelu.cpp:40