2 * Copyright (c) 2019 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 #ifndef __ONERT_COMPILER_PASS_CONSTANT_INSERTION_PASS_H__
18 #define __ONERT_COMPILER_PASS_CONSTANT_INSERTION_PASS_H__
20 #include <compiler/PermuteFactor.h>
22 #include "LoweredOperationPass.h"
23 #include <unordered_map>
33 class ConstantInsertionPass : public LoweredOperationPass
36 using LoweredOperationPass::LoweredOperationPass;
39 std::string id() final { return "ConstantInsertionPass"; }
42 void callback(const ir::OperationIndex &index, ir::Operation &node) final;
47 ir::OperandIndex index;
50 bool operator==(const ReplaceKey &other) const
52 return index == other.index && factor == other.factor;
57 * @brief Structure that provides hash function of ReplaceKey
61 std::size_t operator()(const ReplaceKey &key) const noexcept
64 return hash<ir::OperandIndex>()(key.index) ^ (hash<PermuteFactor>()(key.factor) << 1);
68 std::unordered_map<ReplaceKey, ir::OperandIndex, KeyHasher> _replace_operands_map;
72 } // namespace compiler
75 #endif // __ONERT_COMPILER_PASS_CONSTANT_INSERTION_PASS_H__