ONE - On-device Neural Engine
Loading...
Searching...
No Matches
ElementwiseUnary.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
18#include "ir/OperationVisitor.h"
19
20#include <unordered_map>
21
23{
24
25void ElementwiseUnary::accept(OperationVisitor &v) const { v.visit(*this); }
26
28 const OperandIndexSequence &outputs, const Param &param)
29 : Operation{OperandConstraint::createExact(1u), inputs, outputs,
30 OperandConstraint::createExact(1u)},
31 _param{param}
32{
33}
34
35std::string ElementwiseUnary::name() const
36{
37 using ElementwiseUnaryType = onert::ir::operation::ElementwiseUnary::Type;
38 static const std::unordered_map<ElementwiseUnaryType, std::string> name_map{
39 {ElementwiseUnaryType::ABS, std::string{"Abs"}},
40 {ElementwiseUnaryType::CAST, std::string{"Cast"}},
41 {ElementwiseUnaryType::COS, std::string{"Cos"}},
42 {ElementwiseUnaryType::DEQUANTIZE, std::string{"Dequantize"}},
43 {ElementwiseUnaryType::ERF, std::string{"Erf"}},
44 {ElementwiseUnaryType::EXP, std::string{"Exp"}},
45 {ElementwiseUnaryType::FLOOR, std::string{"Floor"}},
46 {ElementwiseUnaryType::LOG, std::string{"Log"}},
47 {ElementwiseUnaryType::LOGICAL_NOT, std::string{"LogicalNot"}},
48 {ElementwiseUnaryType::NEG, std::string{"Neg"}},
49 {ElementwiseUnaryType::QUANTIZE, std::string{"Quantize"}},
50 {ElementwiseUnaryType::ROUND, std::string{"Round"}},
51 {ElementwiseUnaryType::RSQRT, std::string{"RSqrt"}},
52 {ElementwiseUnaryType::SIN, std::string{"Sin"}},
53 {ElementwiseUnaryType::SQRT, std::string{"Sqrt"}},
54 {ElementwiseUnaryType::SQUARE, std::string{"Square"}},
55 {ElementwiseUnaryType::ZEROS_LIKE, std::string{"ZerosLike"}}};
56 return name_map.at(_param.op_type);
57}
58
59} // namespace onert::ir::operation
ElementwiseUnary(const OperandIndexSequence &inputs, const OperandIndexSequence &outputs, const Param &param)
void accept(OperationVisitor &v) const override
std::string name() const override