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 "FillLayer.h"
19 #include "OperationUtils.h"
21 #include <cker/operation/Fill.h>
32 FillLayer::FillLayer() : _input(nullptr), _value(nullptr), _output(nullptr)
37 void FillLayer::configure(const IPortableTensor *input, const IPortableTensor *value,
38 IPortableTensor *output)
47 switch (_output->data_type())
49 case OperandType::FLOAT32:
50 nnfw::cker::Fill<float *>(getTensorShape(_input), reinterpret_cast<int *>(_input->buffer()),
51 reinterpret_cast<float *>(_value->buffer()),
52 getTensorShape(_output),
53 reinterpret_cast<float *>(_output->buffer()));
55 case OperandType::INT32:
56 nnfw::cker::Fill<int32_t *>(getTensorShape(_input), reinterpret_cast<int *>(_input->buffer()),
57 reinterpret_cast<int32_t *>(_value->buffer()),
58 getTensorShape(_output),
59 reinterpret_cast<int32_t *>(_output->buffer()));
61 case OperandType::UINT32:
62 nnfw::cker::Fill<uint32_t *>(
63 getTensorShape(_input), reinterpret_cast<int *>(_input->buffer()),
64 reinterpret_cast<uint32_t *>(_value->buffer()), getTensorShape(_output),
65 reinterpret_cast<uint32_t *>(_output->buffer()));
68 throw std::runtime_error{"Fill: unsupported data type"};
74 } // namespace backend