ONE - On-device Neural Engine
Loading...
Searching...
No Matches
LogSoftmax.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 "SISOKernel.h"
20
21#include "PALLogSoftmax.h"
22
23namespace luci_interpreter
24{
25
26void configure_kernel_CircleLogSoftmax(const circle::Operator *cur_op,
27 BaseRuntimeGraph *runtime_graph)
28{
29 kernels::SISOKernel kernel(cur_op, runtime_graph);
30
31 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) ==
32 Tensor::element_type(kernel.output()));
33 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input()) ==
34 Tensor::num_elements(kernel.output()));
35 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input()) == Tensor::num_dims(kernel.output()));
36}
37
38void execute_kernel_CircleLogSoftmax(const circle::Operator *cur_op,
39 BaseRuntimeGraph *runtime_graph)
40{
41 kernels::SISOKernel kernel(cur_op, runtime_graph);
42
43 const auto *input_data = runtime_graph->getDataByTensor(kernel.input());
44 assert(input_data);
45 auto *output_data = runtime_graph->getDataByTensor(kernel.output());
46
47 switch (Tensor::element_type(kernel.input()))
48 {
49#ifndef DIS_FLOAT
50 case DataType::FLOAT32:
51 {
52 const float *input_data_float = kernels::getTensorData<float>(input_data);
53 float *output_data_float = kernels::getTensorData<float>(output_data);
54 assert(output_data_float);
55
56 luci_interpreter_pal::LogSoftmax(
57 kernels::getTensorRuntimeShape(kernel.input(), runtime_graph), input_data_float,
58 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph), output_data_float);
59 break;
60 }
61#endif // DIS_FLOAT
62 default:
63 assert(false && "Unsupported type");
64 }
65}
66} // namespace luci_interpreter
uint8_t * getDataByTensor(const circle::Tensor *raw_tensor)
const circle::Tensor * output() const
Definition SISOKernel.h:47
const circle::Tensor * input() const
Definition SISOKernel.h:46
#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 execute_kernel_CircleLogSoftmax(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
void configure_kernel_CircleLogSoftmax(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)