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 "AddNLayer.h"
19 #include "OperationUtils.h"
21 #include <cker/operation/AddN.h>
33 void AddNLayer::configure(std::vector<const IPortableTensor *> &&inputs, IPortableTensor *output)
35 _inputs = std::move(inputs);
41 size_t input_size = _inputs.size();
42 if (_output->data_type() == ir::DataType::INT32)
44 std::vector<const int32_t *> input_buffers(input_size);
45 for (size_t i = 0; i < input_size; i++)
47 input_buffers[i] = getBuffer<int32_t>(_inputs[i]);
49 AddN(getShape(_inputs[0]), input_size, input_buffers.data(), getBuffer<int32_t>(_output));
51 else if (_output->data_type() == ir::DataType::FLOAT32)
53 std::vector<const float *> input_buffers(input_size);
54 for (size_t i = 0; i < input_size; i++)
56 input_buffers[i] = getBuffer<float>(_inputs[i]);
58 AddN(getShape(_inputs[0]), input_size, input_buffers.data(), getBuffer<float>(_output));
62 throw std::runtime_error("AddN: unsupported data type");
68 } // namespace backend