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 "BroadcastToLayer.h"
19 #include <cker/operation/BroadcastTo.h>
30 BroadcastToLayer::BroadcastToLayer() : _input(nullptr), _shape(nullptr), _output(nullptr)
35 void BroadcastToLayer::configure(const IPortableTensor *input, const IPortableTensor *shape,
36 IPortableTensor *output)
43 void BroadcastToLayer::run()
45 // NOTE : It was implemented follows tf.broadcast_to operation works and
46 // Api Document(https://www.tensorflow.org/api_docs/python/tf/broadcast_to)
48 switch (_output->data_type())
50 // ToDo : It need to support INT8 and UINT8 also when will be applied quantization.
51 case OperandType::FLOAT32:
52 nnfw::cker::BroadcastTo<float>(
53 getTensorShape(_input), reinterpret_cast<float *>(_input->buffer()),
54 getTensorShape(_output), reinterpret_cast<float *>(_output->buffer()));
56 case OperandType::INT32:
57 nnfw::cker::BroadcastTo<int32_t>(
58 getTensorShape(_input), reinterpret_cast<int32_t *>(_input->buffer()),
59 getTensorShape(_output), reinterpret_cast<int32_t *>(_output->buffer()));
61 case OperandType::UINT32:
62 nnfw::cker::BroadcastTo<uint32_t>(
63 getTensorShape(_input), reinterpret_cast<uint32_t *>(_input->buffer()),
64 getTensorShape(_output), reinterpret_cast<uint32_t *>(_output->buffer()));
67 throw std::runtime_error{"BroadcastToLayer: unsupported data type"};
73 } // namespace backend