ONE - On-device Neural Engine
Loading...
Searching...
No Matches
SpaceToBatchND.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 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#include "MISOKernel.h"
21
22#include "PALSpaceToBatchND.h"
23
24namespace luci_interpreter
25{
26
27void configure_kernel_CircleSpaceToBatchND(const circle::Operator *cur_op,
28 BaseRuntimeGraph *runtime_graph)
29{
30 kernels::MISOKernel kernel(cur_op, runtime_graph);
31
32 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
33 Tensor::element_type(kernel.output()));
34 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input2()) == DataType::S32);
35 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input3()) == DataType::S32);
36 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.output()) >= 3);
37 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) >= 3);
38 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.output()) <= 4);
39 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) <= 4);
40}
41
42void execute_kernel_CircleSpaceToBatchND(const circle::Operator *cur_op,
43 BaseRuntimeGraph *runtime_graph)
44{
45 kernels::MISOKernel kernel(cur_op, runtime_graph);
46 const int32_t pad_value = 0;
47 switch (Tensor::element_type(kernel.input1()))
48 {
49#ifndef DIS_FLOAT
50 case DataType::FLOAT32:
51 {
52 luci_interpreter_pal::SpaceToBatchND(
53 pad_value, kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph),
54 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.input1())),
55 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph),
56 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(kernel.input2())),
57 kernels::getTensorRuntimeShape(kernel.input3(), runtime_graph),
58 kernels::getTensorData<int32_t>(runtime_graph->getConstDataByTensor(kernel.input3())),
59 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph),
60 kernels::getTensorData<float>(runtime_graph->getDataByTensor(kernel.output())));
61 break;
62 }
63#endif // DIS_FLOAT
64 default:
65 assert(false && "Unsupported type");
66 }
67}
68} // namespace luci_interpreter
uint8_t * getConstDataByTensor(const circle::Tensor *raw_tensor)
uint8_t * getDataByTensor(const circle::Tensor *raw_tensor)
const circle::Tensor * input1() const
Definition MISOKernel.h:64
const circle::Tensor * input2() const
Definition MISOKernel.h:65
const circle::Tensor * input3() const
Definition MISOKernel.h:66
const circle::Tensor * output() const
Definition MISOKernel.h:74
#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 configure_kernel_CircleSpaceToBatchND(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
void execute_kernel_CircleSpaceToBatchND(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)