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() : _value(nullptr), _output(nullptr)
37 void FillLayer::configure(const IPortableTensor *value, IPortableTensor *output)
45 switch (_output->data_type())
47 case OperandType::FLOAT32:
48 nnfw::cker::Fill<float *>(reinterpret_cast<float *>(_value->buffer()),
49 getTensorShape(_output),
50 reinterpret_cast<float *>(_output->buffer()));
52 case OperandType::INT32:
53 nnfw::cker::Fill<int32_t *>(reinterpret_cast<int32_t *>(_value->buffer()),
54 getTensorShape(_output),
55 reinterpret_cast<int32_t *>(_output->buffer()));
57 case OperandType::INT64:
58 nnfw::cker::Fill<int64_t *>(reinterpret_cast<int64_t *>(_value->buffer()),
59 getTensorShape(_output),
60 reinterpret_cast<int64_t *>(_output->buffer()));
62 case OperandType::UINT32:
63 nnfw::cker::Fill<uint32_t *>(reinterpret_cast<uint32_t *>(_value->buffer()),
64 getTensorShape(_output),
65 reinterpret_cast<uint32_t *>(_output->buffer()));
68 throw std::runtime_error{"Fill: unsupported data type"};
74 } // namespace backend