2 * Copyright (c) 2020 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.
17 #include "BatchToSpaceNDLayer.h"
19 #include <cker/operation/BatchToSpaceND.h>
30 BatchToSpaceNDLayer::BatchToSpaceNDLayer()
31 : _input(nullptr), _output(nullptr), _block_shape(nullptr), _crops(nullptr)
36 template <typename T> void BatchToSpaceNDLayer::batchToSpaceNDGeneric()
38 const int32_t NNapiCrops[]{0, 0, 0, 0};
39 const int32_t *_crops_buffer;
41 if (_crops == nullptr)
43 _crops_buffer = NNapiCrops;
47 _crops_buffer = getBuffer<int32_t>(_crops);
49 nnfw::cker::BatchToSpaceND<T>(getShape(_input), getBuffer<T>(_input),
50 getBuffer<int32_t>(_block_shape), _crops_buffer, getShape(_output),
51 getBuffer<T>(_output));
54 void BatchToSpaceNDLayer::configure(const IPortableTensor *input, IPortableTensor *output,
55 IPortableTensor *block_shape, IPortableTensor *crops)
59 _block_shape = block_shape;
63 void BatchToSpaceNDLayer::run()
65 if (_output->data_type() == OperandType::FLOAT32)
67 batchToSpaceNDGeneric<float>();
69 else if (_output->data_type() == OperandType::QUANT_UINT8_ASYMM)
71 batchToSpaceNDGeneric<uint8_t>();
75 throw std::runtime_error{"NYI"};
81 } // namespace backend