2 * Copyright (c) 2021 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.
18 #include "kernels/Utils.h"
20 #include "kernels/BinaryOpCommon.h"
24 namespace luci_interpreter
27 void configure_kernel_CircleNeg(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
29 const auto input_index = cur_op->inputs()->operator[](0);
30 const auto output_index = cur_op->outputs()->operator[](0);
32 assert(input_index != -1);
33 assert(output_index != -1);
35 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
36 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
38 LUCI_INTERPRETER_CHECK(Tensor::element_type(input) == Tensor::element_type(output));
40 assert(Tensor::num_dims(input) == 4);
42 // TODO: enable it only if kernel with dynamic shapes
43 // output-> resize(input->shape());
46 void execute_kernel_CircleNeg(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
48 const auto input_index = cur_op->inputs()->operator[](0);
49 const auto output_index = cur_op->outputs()->operator[](0);
51 assert(input_index != -1);
52 assert(output_index != -1);
54 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
55 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
57 const uint8_t *input_data = runtime_graph->getDataByTensor(input);
58 uint8_t *output_data = runtime_graph->getDataByTensor(output);
60 assert(input_data != nullptr);
61 assert(output_data != nullptr);
63 switch (Tensor::element_type(input))
66 case DataType::FLOAT32:
68 luci_interpreter_pal::Negate(
69 kernels::getTensorShape(input), kernels::getTensorData<float>(input_data),
70 kernels::getTensorShape(output), kernels::getTensorData<float>(output_data));
75 assert(false && "Unsupported type.");
79 } // namespace luci_interpreter