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 "OneHotLayer.h"
19 #include "OperationUtils.h"
21 #include <cker/operation/OneHot.h>
32 void OneHotLayer::oneHotFloat32()
34 nnfw::cker::OneHot<float, int32_t>(
35 _depth, _on_value, _off_value, _axis, convertTensorToCkerShape(_indices),
36 reinterpret_cast<const int32_t *>(_indices->buffer()), convertTensorToCkerShape(_output),
37 reinterpret_cast<float *>(_output->buffer()));
40 void OneHotLayer::oneHotQuant8() { throw std::runtime_error{"OneHot NYI for quantized"}; }
42 void OneHotLayer::configure(const operand::Tensor *indices, operand::Tensor *output, int32_t depth,
43 float on_value, float off_value, int32_t axis)
49 _off_value = off_value;
52 _axis = _indices->num_dimensions();
55 void OneHotLayer::run()
57 if (_output->data_type() == OperandType::FLOAT32)
61 else if (_output->data_type() == OperandType::QUANT8_ASYMM)
69 } // namespace backend