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.
19 #include "OperationUtils.h"
21 #include <cker/operation/MaxMin.h>
32 template <typename T> void MaxLayer::maximum()
34 nnfw::cker::Max<T>(getTensorShape(_lhs), reinterpret_cast<const T *>(_lhs->buffer()),
35 getTensorShape(_rhs), reinterpret_cast<const T *>(_rhs->buffer()),
36 getTensorShape(_output), reinterpret_cast<T *>(_output->buffer()));
39 void MaxLayer::maxQuant8()
41 if (_lhs->data_scale() == _rhs->data_scale() && _lhs->data_scale() == _output->data_scale())
43 if (_lhs->data_offset() == _rhs->data_offset() && _lhs->data_offset() == _output->data_offset())
45 return nnfw::cker::Max<uint8_t>(
46 getTensorShape(_lhs), reinterpret_cast<const uint8_t *>(_lhs->buffer()),
47 getTensorShape(_rhs), reinterpret_cast<const uint8_t *>(_rhs->buffer()),
48 getTensorShape(_output), reinterpret_cast<uint8_t *>(_output->buffer()));
51 throw std::runtime_error("Max NYI for quantized");
54 void MaxLayer::configure(const IPortableTensor *lhs, const IPortableTensor *rhs,
55 IPortableTensor *output)
57 assert(lhs != nullptr);
58 assert(rhs != nullptr);
59 assert(output != nullptr);
68 if (_lhs->data_type() == OperandType::FLOAT32)
72 else if (_lhs->data_type() == OperandType::QUANT_UINT8_ASYMM)
78 throw std::runtime_error{"Max: unsupported data type"};
84 } // namespace backend