ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Floor.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
3 * Copyright 2019 The TensorFlow Authors. All Rights Reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include "Builders.h"
19#include "kernels/Utils.h"
20
21#include "PALFloor.h"
22
23namespace luci_interpreter
24{
25void configure_kernel_CircleFloor(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
26{
27 const auto input_index = cur_op->inputs()->operator[](0);
28 const auto output_index = cur_op->outputs()->operator[](0);
29
30 assert(input_index != -1);
31 assert(output_index != -1);
32
33 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
34 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
35
36 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == Tensor::element_type(output));
37 // check that input and output dimensions are equal
38 int N = kernels::getTensorShape(input).dimensionsCount();
39 LUCI_INTERPRETER_CHECK(N == kernels::getTensorShape(output).dimensionsCount());
40
41 // check that sizes of all dimensions are equal
42 for (int i = 0; i < N; ++i)
43 {
45 kernels::getTensorShape(output).dims(i));
46 }
47}
48
49void execute_kernel_CircleFloor(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
50{
51
52 const auto input_index = cur_op->inputs()->operator[](0);
53 const auto output_index = cur_op->outputs()->operator[](0);
54
55 assert(input_index != -1);
56 assert(output_index != -1);
57
58 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
59 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
60
61 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
62 uint8_t *output_data = runtime_graph->getDataByTensor(output);
63
64 assert(input_data != nullptr);
65 assert(output_data != nullptr);
66
67 switch (Tensor::element_type(input))
68 {
69#ifndef DIS_FLOAT
70 case DataType::FLOAT32:
71
73 kernels::getTensorShape(input), kernels::getTensorData<float>(input_data),
74 kernels::getTensorShape(output), kernels::getTensorData<float>(output_data));
75
76 break;
77#endif // DIS_FLOAT
78 default:
79 assert(false && "Unsupported type.");
80 }
81}
82
83} // namespace luci_interpreter
const circle::Tensor * getCircleTensorByIndex(int32_t index)
uint8_t * getDataByTensor(const circle::Tensor *raw_tensor)
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
Definition Utils.h:194
void Floor(const luci_interpreter::RuntimeShape &input_shape, const float *input_data, const luci_interpreter::RuntimeShape &output_shape, float *output_data)
void execute_kernel_CircleFloor(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
Definition Floor.cpp:49
void configure_kernel_CircleFloor(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
Definition Floor.cpp:25