ONE - On-device Neural Engine
Loading...
Searching...
No Matches
MinMaxMap.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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
17#ifndef __ONERT_EXEC_MINMAX_MAP_H__
18#define __ONERT_EXEC_MINMAX_MAP_H__
19
20#include "ir/Index.h"
21#include "util/MinMaxMap.h"
22
23namespace onert::exec
24{
25
26/*
27 * NOTE: To record MinMax, the key would be better to use Tensor ID in circle.
28 * But in general, onert does not keep track of circle tensor ID to onert tensor ID.
29 * The ordering in tensors in onert may be different from ordering in circle
30 * because onert could try optimization (reusing allocation, removing redundant tensors,
31 * code optimization, ...)
32 * For Linear Executor and CPU backcend, onert keep track of op index in generated Code.
33 * MinMaxMap uses operation index instead.
34 *
35 * TODO: Stop recording in case of onert internal optimization (e.g. code fusion) occcurs.
36 * It rarely happens since most fusioning is done by compiler frontend, not by onert.
37 */
39{
40 size_t operator()(
41 const std::tuple<ir::ModelIndex, ir::SubgraphIndex, ir::OperationIndex> &k) const noexcept
42 {
43 return std::hash<ir::ModelIndex>()(std::get<ir::ModelIndex>(k)) ^
44 std::hash<ir::SubgraphIndex>()(std::get<ir::SubgraphIndex>(k)) ^
45 std::hash<ir::OperationIndex>()(std::get<ir::OperationIndex>(k));
46 }
47};
50
52{
53 size_t
54 operator()(const std::tuple<ir::ModelIndex, ir::SubgraphIndex, ir::IOIndex> &k) const noexcept
55 {
56 return std::hash<ir::ModelIndex>()(std::get<ir::ModelIndex>(k)) ^
57 std::hash<ir::SubgraphIndex>()(std::get<ir::SubgraphIndex>(k)) ^
58 std::hash<ir::IOIndex>()(std::get<ir::IOIndex>(k));
59 }
60};
63} // namespace onert::exec
64
65#endif // __ONERT_EXEC_MINMAX_MAP_H__
size_t operator()(const std::tuple< ir::ModelIndex, ir::SubgraphIndex, ir::IOIndex > &k) const noexcept
Definition MinMaxMap.h:54
size_t operator()(const std::tuple< ir::ModelIndex, ir::SubgraphIndex, ir::OperationIndex > &k) const noexcept
Definition MinMaxMap.h:40